# Arup Guha
# 6/12/2018
# Program to convert a single index into a 2D grid into row and column.
# Indexes are given in row major order.

# Get the user input.
rows = int(input("How many rows in your grid?\n"))
cols = int(input("How many columns in your grid?\n"))
index = int(input("Which index to you want to find in the grid?\n"))

# Convert to feet and inches via int div and mod.
rowIndex = index//cols
colIndex = index%cols

# Print the converted height
print("Your value can be found at row", rowIndex,"and column",colIndex)

# Get the row and column of the entry.
rowNum = int(input("What row is your entry?\n"))
colNum = int(input("What column is your entry?\n"))

# Convert to its single index and print it out.
index = rowNum*cols + colNum
print("Your location has a single index of",index)
