CodeEff/ECCO huggingface dataset:
# Original solution
n, m = list(map(int, input().split()))                    
route_lists = [input().split() for i in range(m)]   
new_lists = []                                      
for i in route_lists:                               
  for j in range(2):                                
    new_lists.append(i[j])                          
                                                    
new_lists.sort()                                    
for i in range(1, n+1, 1):                          
  print((new_lists.count(str(i))))                    

# Optimized solution
n, m = list(map(int, input().split()))                    
route_lists = [input().split() for i in range(m)]   
new_lists = []                                      
for i in route_lists:                               
  for j in range(2):                                
    new_lists.append(i[j])                          
                                                                                      
for i in range(1, n+1, 1):                          
  print((new_lists.count(str(i))))
# Original solution
n, m = list(map(int, input().split()))

d = []
for i in range(m):
    a, b = list(map(int, input().split()))
    d.append(a)
    d.append(b)
d = sorted(d)
for i in range(1, n + 1):
  count = 0
  for j in range(len(d)):
    if d[j] == i:
      count += 1
  print(count)
  



# Optimized solution
n, m = list(map(int, input().split()))

d = [0]*n
 
for i in range(m):
    a, b = list(map(int, input().split()))
    d[a - 1] += 1
    d[b - 1] += 1

for i in d:
    print(i)
# Original solution
n, m = (int(i) for i in input().split())
city2city = [0] * n
for i in range(m):
    a,b = (int(i) for i in input().split())
    city2city[a-1] += 1
    city2city[b-1] += 1

for c in city2city:
    print(c)


# Optimized solution
def main():
    N, M = (int(i) for i in input().split())
    c = [0 for i in range(N)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        c[a-1] += 1
        c[b-1] += 1
    print(*c, sep="\n")


if __name__ == '__main__':
    main()
# Original solution
N,_,*L=map(int,open(0).read().split())
A=[0]*N
for l in L: A[l-1]+=1
print(*A,sep='\n')


# Optimized solution
N,_,*L=list(map(int,open(0).read().split()))
for n in range(N):print((L.count(n+1)))
# Original solution
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    N, M = map(int, input().split())
    ans = [0]*N

    for i in range(M):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        ans[ai] += 1
        ans[bi] += 1

    print(*ans, sep='\n')
 
if __name__ == '__main__':
    solve()


# Optimized solution
import sys

def solve():
    N, M = map(int, input().split())

    deg = [0] * N

    for i in range(M):
        ai, bi = map(int, input().split())
        ai, bi = ai - 1, bi - 1
        deg[ai] += 1
        deg[bi] += 1

    print(*deg, sep='\n')

if __name__ == '__main__':
    solve()
# Original solution
from collections import Counter
n,m=list(map(int,input().split()))
L=[0]*(2*m)
for i in range(m):
    L[2*i],L[2*i+1]=list(map(int,input().split()))
s=Counter(L)
for i in range(n):
    print((s[i+1]))

# Optimized solution
n,m=map(int,input().split())
ans=[0]*n
for _ in range(m):
    a,b=map(int,input().split())
    ans[a-1] += 1
    ans[b-1] += 1
print(*ans, sep="\n")
# Original solution
N,M= list(map(int,input().split()))
f = [0] * (N + 2)
for i in range(M):
    x,y = list(map(int,input().split()))
    f[x]+=1
    f[y]+=1
for i in range(1,N+1):
    print((f[i]))

# Optimized solution
# 061 B
N,M= list(map(int,input().split()))
f = [0] * (N + 20)
for i in range(M):
    x,y = list(map(int,input().split()))
    f[x]+=1
    f[y]+=1
for i in range(1,N+1):
    print((f[i]))
# Original solution
n, m = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = list(map(int, input().split()))
count = 0

for i in range(1, n + 1):
    count = a.count(i) + b.count(i)
    print(count)

# Optimized solution
n, m = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = list(map(int, input().split()))

road = [0] * n

for i in range(m):
    road[a[i] - 1] += 1
    road[b[i] - 1] += 1

for i in range(n):
    print((road[i]))
# Original solution
# -*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

N, M = list(map(int, input().split()))
l = []
for i in range(N):
    l.append(0)

for i in range(M):
    a, b = list(map(int, input().split()))
    a -= 1; b -= 1;
    l[a] += 1
    l[b] += 1

for i in range(N):
    print((l[i]))




# Optimized solution
# -*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

N, M = list(map(int, input().split()))
l = [0] * N

for i in range(M):
    a, b = list(map(int, input().split()))
    a -= 1; b -= 1;
    l[a] += 1
    l[b] += 1

for i in range(N):
    print((l[i]))
# Original solution
from collections import defaultdict
N, M = list(map(int, input().split()))
city_road_nums = defaultdict(int)

for _ in range(M):
    a, b = list(map(int, input().split()))
    city_road_nums[a] += 1
    city_road_nums[b] += 1

for i in range(1, N+1):
    print((city_road_nums[i]))


# Optimized solution
N, M = list(map(int, input().split()))
ABs = [input().split() for i in range(M)]
 
 
MPs = {}
for a, b in ABs:
    a = int(a)
    b = int(b)
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1
 
for mp in range(1, N+1):
    if mp not in MPs:
        MPs[mp] = '0'
 
for _, y in sorted(MPs.items()):
    print(y)
# Original solution
N, M = list(map(int, input().split()))

A = []
B = []
for i in range(M):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
AB = A + B

# 各都市間の道路の本数は、ABに含まれる各都市の個数（番号）に等しい
roadsCntArray = []
# 入力に含まれる都市の個数を数える
for i in range(N):
    roadsCntArray.append(AB.count(i+1))

for i in range(N):
    print((roadsCntArray[i]))

# Optimized solution
N, M = list(map(int, input().split()))

A = []
B = []
for i in range(M):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
AB = A + B

# 各都市間の道路の本数は、ABに含まれる各都市の個数（番号）に等しい
roadsCntArray = []
# 入力に含まれる都市の個数を数える
for i in range(N):
    roadsCntArray.append(AB.count(i+1))
    print((roadsCntArray[i]))
# Original solution
n, m = list(map(int, input().split()))
RD = list(list(map(int, input().split())) for _ in range(m))
for i in range(1, n + 1):
    ans = 0
    for j in RD:
        ans += j.count(i)
    print(ans)

# Optimized solution
n, m = list(map(int, input().split()))
NRD = list(0 for i in range(n))
for i in range(m):
    r1, r2 = list(map(int, input().split()))
    NRD[r1 - 1] += 1
    NRD[r2 - 1] += 1
for i in range(n):
    print((NRD[i]))
# Original solution
N,M=list(map(int,input().split()))
li=[]
for i in range(M):
    a,b=list(map(int,input().split()))
    li.append(a)
    li.append(b)
ans=[0]*N
for j in range(1,N+1):
    cj=li.count(j)
    ans[j-1]=cj
for k in range(N):
    print((ans[k]))


# Optimized solution
N,M=list(map(int,input().split()))
li=[0]*N
for i in range(M):
    a,b=list(map(int,input().split()))
    li[a-1]+=1
    li[b-1]+=1
for j in range(N):
    print((li[j]))
# Original solution
a = list(map(int,input().split()))
b = [list(map(int,input().split())) for i in range(a[1])]
c = []

for i in range(a[0]):
  d = []
  for j in range(a[1]):
    d.append(b[j].count(i+1))
  else:
    c.append(sum(d))
else:
  for i in range(a[0]):
    print((c[i]))

# Optimized solution
N,M = list(map(int,input().split()))
z = []

for i in range(M):
  a,b = list(map(int,input().split()))
  z.append(a)
  z.append(b)

for i in range(N):
  print((z.count(i+1)))
# Original solution
N,M,*A=list(map(int,open(0).read().split()));l=[0]*N
for a,b in zip(A[::2],A[1::2]):l[a-1]+=1;l[b-1]+=1
for r in l:print(r)

# Optimized solution
N,M,*A=list(map(int,open(0).read().split()));l=[0]*N
for a in A:l[a-1]+=1
for r in l:print(r)
# Original solution
def getlist():
    return list(map(int, input().split()))

n,m = getlist()

cities = [0 for i in range(n)]
for i in range(m):
    a,b = getlist()
    cities[a-1] += 1
    cities[b-1] += 1

print(("\n".join(list(map(str, cities)))))

# Optimized solution
n,m = list(map(int, input().split()))
cities = [0 for i in range(n)]
for i in range(m):
    bridges = list(map(int, input().split()))
    cities = [x+1 if i+1 in bridges else x for i,x in enumerate(cities)]
print(("\n".join(list(map(str, cities)))))
# Original solution
n,m = list(map(int, input().split()))
adj = [[] for i in range(n)]
for i in range(m):
    a,b = list(map(int, input().split()))
    a-=1
    b-=1
    adj[a].append(b)
    adj[b].append(a)
for i in adj:
    print((len(i)))

# Optimized solution
N,M = (int(x) for x in input().split())

result = [0]*N
for i in range(M):
	a,b = (int(x) for x in input().split())
	result[a-1] += 1
	result[b-1] += 1

for i in result:
	print(i)
# Original solution
N, M = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(M)]

d = {}
for i in range(1,N+1):
  d[i] = 0

for i in range(M):
  a, b = A[i][0], A[i][1]
  d[a] += A[i].count(a)
  d[b] += A[i].count(b)

for k, v in list(d.items()):
  print(v)

# Optimized solution
N, M  = list(map(int,input().split()))
d = [0]*(N)
for _ in range(M):
  a, b = list(map(int,input().split()))
  d[a-1] += 1
  d[b-1] += 1
for v in d:
  print(v)
# Original solution
n,m = list(map(int,input().split()))
abm = [list(map(int,input().split())) for _ in range(m)]

countDic = {}

for nn in range(n+1):
	countDic[nn] = 0
	
for ab in abm:
	countDic[ab[0]] += 1
	countDic[ab[1]] += 1

ks = list(countDic.keys())
ks = sorted(ks)[1:]

for k in ks:
	print((countDic[k]))

# Optimized solution
n,m = list(map(int,input().split()))

ans = [0]*n
for _ in range(m):
	a,b = list(map(int,input().split()))
	ans[a-1]+=1
	ans[b-1]+=1
	
for an in ans:
	print(an)
# Original solution
n,m=list(map(int,input().split()))
ls=[0]*(n+1)
for i in range(m):
    a,b= list(map(int,input().split()))
    ls[a]+=1
    ls[b]+=1
for j in range(1,n+1):
    print((ls[j]))

# Optimized solution
n,m=list(map(int,input().split()))
s=[0]*(n+1)
for i in range(m):
    a,b=list(map(int,input().split()))
    s[a]+=1
    s[b]+=1
for i in range(1,n+1):
    print((s[i]))
# Original solution
N,M = list(map(int,input().split()))
cint = [0,0]*M

for i in range(M):
    cint[i]=list(map(int,input().split()))

for i in range(1,N+1):
    count=0
    for j in range(M):
        if cint[j][0] == i or  cint[j][1] == i:
            count +=1
    print(count)

# Optimized solution
N,M = list(map(int,input().split()))
count =[0]*N

for i in range(M):
    ca,cb=list(map(int,input().split()))
    count[ca-1] +=1
    count[cb-1] +=1

for i in range(N):
    print((count[i]))
# Original solution
n = int(input())

dice = [[0 for i in range(6)] for j in range(n)]
for i in range(n):
    dice[i] = list(map(int, input().split()))
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
def dice_matching(dice1, dice2):
    if dice1[1] == dice2[1]:
        for i in range(4):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0
        
flag = 0
for i in range(n):
    for j in range(i+1, n):
        count = 0
        while(1):
            if dice_matching(dice[i], dice[j]) == 1:
                flag = 1
                print('No')
                break
            else:
                if count < 3:
                    rolling('N', dice[j])
                    count += 1
                elif 7 > count and count >= 3:
                    if count == 3:
                        rolling('E', dice[j])
                    rolling('N', dice[j])
                    count += 1
                else:
                    break
        if flag ==1:
            break
    if flag == 1:
        break
if flag == 0:
    print('Yes')

# Optimized solution
n = int(input())

dice = [[0 for i in range(6)] for j in range(n)]
for i in range(n):
    dice[i] = list(map(int, input().split()))
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
def dice_matching(dice1, dice2):
    if dice1[1] == dice2[1]:
        for i in range(4):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0

def alldice_matching(dice1, dice2):
    count = 0
    while(1):
        if dice_matching(dice1, dice2) == 1:
            return 1
        else:
            if count < 3:
                rolling('N', dice2)
                count += 1
            elif 7 > count and count >= 3:
                if count == 3:
                    rolling('E', dice2)
                rolling('N', dice2)
                count += 1
            else:
                return 0

flag = 0
for i in range(n):
    for j in range(i+1, n):
        if alldice_matching(dice[i], dice[j]) == 1:
            flag = 1
            print("No")
            break
    if flag == 1:
        break
if flag == 0:
    print('Yes')
# Original solution
from itertools import*
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
lst=list(combinations(a,2))
for d,e in lst:
 for i in range(6):
  m=('012345','152043','215304','302541','410352','514320')[i]
  f=[d[int(k)]for k in m]
  if f[0]==e[0]and f[5]==e[5]:
   f=f[1:5]*2
   for j in range(4):
    if f[j:j+4]==e[1:5]:t=1
print((('Yes','No')[t==1]))


# Optimized solution
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
t=0
for i in range(n-1):
 d=a[i]
 for j in range(i+1,n):
  e=a[j]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:t=1
print((('Yes','No')[t]))
# Original solution
import sys
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
for i in range(n-1):
 d=a[i][:];d[3],d[4]=d[4],d[3]
 for j in range(i+1,n):
  e=a[j][:];e[3],e[4]=e[4],e[3]
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(k)]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:print('No');sys.exit()
print('Yes')


# Optimized solution
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    if f[0]==e[0]and f[5]==e[5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return print('No')
 print('Yes')
f()
# Original solution
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    g=f[1:5]*2
    for k in range(4):
     if g[k:k+4]==e[1:5]:
      if f[0]==e[0]:
       if f[5]==e[5]:return 'No'
 return 'Yes'
print((f()))


# Optimized solution
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    if f[0]==e[0]:
     if f[5]==e[5]:
      f=f[1:5]*2
      for k in range(4):
       if f[k:k+4]==e[1:5]:return 'No'
 return 'Yes'
print((f()))
# Original solution
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    f=[d[k]for k in p]
    if f[0]==e[0]and f[5]==e[5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((f()))


# Optimized solution
n=int(eval(input()))
a=[[int(s)for s in input().split()]for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    f=[d[k]for k in p]
    if f[0]==e[0]and f[5]==e[5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((f()))
# Original solution
from itertools import*
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for p,q in list(combinations(a,2)):
  d=p[:];d[3],d[4]=d[4],d[3]
  e=q[:];e[3],e[4]=e[4],e[3]
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[k]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((f()))


# Optimized solution
from itertools import*
n=int(eval(input()))
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
def f():
 for d,e in list(combinations(a,2)):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[k]for k in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((f()))
# Original solution
from itertools import*
def g():
 n=int(eval(input()))
 a=[[s for s in input().split()]for _ in range(n)]
 for b in a:
  b[3:5]=b[4],b[3]
 t=0
 for d,e in combinations(a,2):
  for p in('012345','152043','215304','302541','410352','514320'):
   f=[d[int(i)]for i in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:t=1
 print((['Yes','No'][t]))
g()


# Optimized solution
from itertools import*
n=int(eval(input()))
a=[input().split()for _ in[0]*n]
for b in a:
 b[3:5]=b[4],b[3]
def f():
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[i]for i in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((f()))
# Original solution
from itertools import*
n=int(eval(input()))
a=[input().split()for _ in[0]*n]
for b in a:
 b[3:5]=b[4],b[3]
def f():
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[i]for i in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((f()))


# Optimized solution
from itertools import*
n=int(eval(input()))
a=[input().split()for _ in[0]*n]
for b in a:
 b[3:5]=b[4],b[3]
def g():
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[i]for i in p]
   if f[0::5]==e[0::5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print((g()))
# Original solution
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
    
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}

    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]

        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c

def mk_dice():
    u,s,e,w,n,d=list(map(int,input().split()))
    return Dice(u,w,s,e,n,d)

import random
q=int(eval(input()))
dice_col=[]
ans=True
for j in range(q):
    dice_b=mk_dice()
    for dice in dice_col:
        for i in range (1000):
            dice.rot(random.randint(0,3))
            if(dice.u==dice_b.u and dice.d==dice_b.d and dice.w==dice_b.w and dice.s==dice_b.s and dice.e==dice_b.e and dice.n==dice_b.n):
                ans=False
    dice_col.append(dice_b)

if ans:
    print('Yes')
else:
    print('No')

# Optimized solution
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
    def get_nums(self):   
        return {self.u,self.w,self.s,self.e,self.n,self.w,self.d}

def mk_dice():
    u,s,e,w,n,d=list(map(int,input().split()))
    return Dice(u,w,s,e,n,d)
 
import random
q=int(eval(input()))
dice_col=[]
ans=True
for j in range(q):
    dice_b=mk_dice()
    for dice in dice_col:
        if(dice.get_nums()==dice_b.get_nums()):
            for i in range (1000):
                dice.rot(random.randint(0,2))
                if(dice.u==dice_b.u and dice.d==dice_b.d and dice.w==dice_b.w and dice.s==dice_b.s and dice.e==dice_b.e and dice.n==dice_b.n):
                    ans=False
    dice_col.append(dice_b)
 
if ans:
    print('Yes')
else:
    print('No')