Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, b):
  for i in range(n):
    for j in range(i):
      if s[i][(j + b) % n] != s[j][(i + b) % n]:
        return 0
  return 1

def not_eq(s, b, n, i, j):
  return s[i][(j + b) % n] != s[j][(i + b) % n]

def yoi2(s, b):
  if sum(not_eq(s, b, n, i, j) for i in range(n) for j in range(i)) > 0:
        return 0
  return 1

sol = n * sum(yoi2(s, b) for b in range(n))
print(sol)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]


def eq(s, b, n, i, j):
  return s[i][(j + b) % n] != s[j][(i + b) % n]

def yoi2(s, b):
  for i in range(n):
    for j in range(i):
      if eq(s, b, n, i, j):
        return 0
  return 1

sol = n * sum(yoi2(s, b) for b in range(n))
print(sol)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, b):
  for i in range(n):
    for j in range(i):
      if s[i][(j + b) % n] != s[j][(i + b) % n]:
        return 0
  return 1

sol = n * sum(yoi(s, b) for b in range(n))
print(sol)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, b):
  for i in range(n):
    for j in range(i):
      if s[i % n][(j + b) % n] != s[j % n][(i + b) % n]:
        return 0
  return 1


sol = n * sum(yoi(s, b) for b in range(n))
print(sol)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, b):
  for i in range(n):
    for j in range(i+1, n):
      if s[i % n][(j + b) % n] != s[j % n][(i + b) % n]:
        return 0
  return 1

sol = sum(yoi(s, b) for b in range(n))
print(sol * n)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n)]


def check

def yoi(s, b):
  for i in range(n):
    for j in range(i+1, n):
      if s[i % n][(j + b) % n] != s[j % n][(i + b) % n]:
        return 0
  return 1

sol = sum(yoi(s, b) for b in range(n))
print(sol * n)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, a, b):
  for i in range(n):
    for j in range(i+1, n):
      if s[(i + a) % n][(j + b) % n] != s[(j + a) % n][(i + b) % n]:
        return 0
  return 1

sol = sum(yoi(s, 0, b) for b in range(n))
print(sol * n)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, a, b):
  for i in range(n):
    for j in range(i+1, n):
      if s[(i + a) % n][(j + b) % n] != s[(j + a) % n][(i + b) % n]:
        return 0
  return 1

sol = sum(yoi(s, a, b) for a in range(n) for b in range(n))
print(sol)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

def yoi(s, a, b):
  for i in range(n):
    for j in range(n):
      if s[(i + a) % n][(j + b) % n] != s[(j + a) % n][(i + b) % n]:
        return 0
  return 1

sol = sum(yoi(s, a, b) for a in range(n) for b in range(n))
print(sol)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
st = [str().join(s_) for s_ in zip(*s)]

sol = 0

for i in range(n):
    for k in range(n):
        if s[k] != st[k]:
            break
    else:
        sol += 1
    
    s = [s_l[1:]+s_l[0] for s_l in s]
    st = st[1:] + [st[0]]
    
print(sol * n)