Problem:
 Score : 200 points    Problem Statement There are N cities and M roads.
The i -th road (1≤i≤M) connects two cities a_i and b_i  (1≤a_i,b_i≤N) bidirectionally.
There may be more than one road that connects the same pair of two cities.
For each city, how many roads are connected to the city?      Constraints  2≤N,M≤50  1≤a_i,b_i≤N  a_i ≠ b_i  All input values are integers.         Input Input is given from Standard Input in the following format:  N  M  a_1  b_1  :  a_M  b_M       Output Print the answer in N lines.
In the i -th line (1≤i≤N) , print the number of roads connected to city i .        Sample Input 1 4 3
1 2
2 3
1 4      Sample Output 1 2
2
1
1   City 1 is connected to the 1 -st and 3 -rd roads.  City 2 is connected to the 1 -st and 2 -nd roads.  City 3 is connected to the 2 -nd road.  City 4 is connected to the 3 -rd road.        Sample Input 2 2 5
1 2
2 1
1 2
2 1
1 2      Sample Output 2 5
5       Sample Input 3 8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8      Sample Output 3 3
3
2
2
2
1
1
2

Solution (Python):
n, m = map(int, input().split())
ci = []
for i in range(n + 1):
    ci.append(0)
for i in range(m):
    li = list(map(int, input().split()))
    for i in range(n + 1):
        if i in li:
            ci[i] += 1
for i in range(1, n + 1):
    print(ci[i])

Solution (Python):
n, m = map(int, input().split())

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

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

for i in range(1, n + 1):
    print(d[i])

Solution (Python):
N, M = map(int,input().split())
L=[0]*N
for i in range(M):
  x,y = map(int,input().split())
  L[x-1] += 1
  L[y-1] += 1

for j in range(N):
  print(L[j])

Solution (Python):
N,M=map(int,input().split())
ans=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    ans[a-1]+=1
    ans[b-1]+=1
for i in ans:print(i)

Solution (Python):
N, M = map(int, input().split())
k = [0]*N
for _ in range(M):
	a, b = map(int, input().split())
	k[a-1] += 1
	k[b-1] += 1

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

Solution (Python):
import numpy as np

N,M=(int(x) for x in input().split())
c=np.zeros(50)
for i in range(M):
    a,b=(int(x) for x in input().split())
    c[a-1]=c[a-1]+1
    c[b-1]=c[b-1]+1
for i in range(N):
    print(int(c[i]))

Solution (Python):
n,m = map(int,input().split())
road_list=[0 for _ in range(n)]

for _ in range(m):
  a,b = map(int,input().split())
  road_list[a-1]+=1
  road_list[b-1]+=1
for i in range(n):
  print(road_list[i])

Solution (Python):
import sys
input=sys.stdin.readline

n,m = map(int, input().split())
x = [0]*n

for i in range(m):
    a,b = map(int, input().split())
    x[a-1] += 1
    x[b-1] += 1

for i in x:
    print(i)

Solution (Python):
N, M = map(int, input().split())
a = []
b = []
for i in range(M):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

for i in range(N):
    r = 0
    r += a.count(i+1)
    r += b.count(i+1)
    print(r)

Solution (Python):
n,m = map(int,input().split())
d={j:0 for j in range(1,n+1)}
for i in range(m):
    a,b = map(int,input().split())
    d[a] = d[a]+1
    d[b] = d[b]+1
for k in range(1,n+1):
    print(d[k])

Solution (Python):
N, M = map(int, input().split())
c = [0] * N

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

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

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 




 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    ans = [0 for i in range(N)]
    
    for _ in range(M):
        a,b = inputMap()
        ans[a-1] += 1
        ans[b-1] += 1
        
    for i in ans:
        print(i)
    
if __name__ == "__main__":
	main()

Solution (Python):
n,m = map(int,input().split())
r = [0 for _ in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  r[a-1] += 1
  r[b-1] += 1
for j in range(n):
  print(r[j])

Solution (Python):
N, M = map(int, input().split())
D = [0]*N
for i in range(M):
    a, b = map(int, input().split())
    D[a-1] += 1
    D[b-1] += 1
for i in range(N):
    print(str(D[i]))

Solution (Python):
N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(M)]

ret = [0] * N
for a, b in ab :
    ret[a-1] += 1
    ret[b-1] += 1
    
print("\n".join(map(str, ret)))

Solution (Python):

n,m=map(int,input().split())

ans=[0]*n

total=[]

for i in range(m):
    c=sorted(list(map(int,input().split())))
    ans[c[0]-1]+=1
    ans[c[1]-1]+=1
    total.append(c)

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

Solution (Python):
n,m=map(int,input().split())
a=[0]*n
for i in range(m):
  x,y=map(int,input().split())
  a[x-1]+=1
  a[y-1]+=1

for j in range(n):
  print(a[j])

Solution (Python):
n,m=map(int,input().split())
a=[]
ab=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
  a+=[ab[i][0]]+[ab[i][1]]
for i in range(1,n+1):
  print(a.count(i))

Solution (Python):
N,M,*roads = map(int,open(0).read().split())
for i in range(1,N+1):print(roads.count(i))

Solution (Python):
N,M=map(int,input().split()[:2])
rails=[0]*N

for i in range(M):
    a,b=map(int,input().split()[:2])
    rails[a-1]+=1
    rails[b-1]+=1
for i in range(N):
    print(rails[i])

Solution (Python):
from collections import Counter

N, M = [int(v) for v in input().split()]
c = Counter()
for _ in range(M):
    a, b = [v for v in input().split()]
    c[a] += 1
    c[b] += 1
for i in range(N):
    print(c[str(i + 1)])

Solution (Python):
N,M=map(int,input().split())
t=[]
for i in range(M):
    t.append(list(map(int,input().split())))
for i in range(1,N+1):
    a=0
    for j in range(M):
        if i in t[j]:
            a+=1
    print(a)

Solution (Python):
from collections import defaultdict


n, m = map(int, (input().split()))
route_dict = defaultdict(int)

for i in range(m):
    a, b = map(int, input().split())
    route_dict[a] += 1
    route_dict[b] += 1

for k in range(1, n+1):
    print(route_dict[k])

Solution (Python):
import numpy as np

ncity, nlines = map(int, input().rstrip("\n").split())
matrix = np.zeros((ncity, ncity), dtype=int)
for _ in range(nlines):
    l, c = map(lambda x: int(x) - 1, input().rstrip("\n").split())
    matrix[l][c] += 1
    matrix[c][l] += 1

for list_ in matrix:
    print(sum(list_))

Solution (Python):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]
ab_plane = []

for i in range(len(ab)):
    ab_plane.append(ab[i][0])
    ab_plane.append(ab[i][1])

for i in range(N):
    print(ab_plane.count(i+1))

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

Solution (Python):
n, m = map(int,input().split())
x = [0 for x in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    x[a-1]+=1
    x[b-1]+=1

for i in range(n):
    print(x[i])

Solution (Python):
n,m = map(int,input().split())
a = [input().split() for i in range(m)]
for i in range(1,n+1):
  b = 0
  for j in range(m):
    b += a[j].count(str(i))
  print(b)

Solution (Python):
n, m = map(int, input().split())
a=[]
for i in range(m):
  u = map(int, input().split())
  a += u
b=[]
for i in range(1, n + 1):
  b += [a.count(i)]
for i in b:
  print(i)

Solution (Python):
N, M = map(int, input().split())
ans = [0 for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    ans[a - 1] += 1
    ans[b - 1] += 1
    
for a in ans:
    print(a)

Solution (Python):


import sys
input = sys.stdin.readline


def main():
    n, m = map(int, input().split())

    l = [[None, None] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        l[i][0] = a
        l[i][1] = b

    ans = [0] * n
    for i in l:
        ans[i[0] - 1] += 1
        ans[i[1] - 1] += 1

    for i in ans:
        print(i)


if __name__ == '__main__':
    main()

Solution (Python):
a, b = map(int, input().split())
c = [0] * a
for i in range(b):
    d, e = map(int, input().split())
    c[d-1] += 1
    c[e-1] += 1
for i in c:
    print(i)

Solution (Python):
n,m=map(int,input().split())
con=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  con[a-1].append(b)
  con[b-1].append(a)
for i in range(n):
  print(len(con[i]))

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

Solution (Python):
n,m = map(int, input().split())
li = [0]*n
for i in range(m):
    a,b = map(int, input().split())
    li[a-1]+=1
    li[b-1]+=1
for j in range(n):
    print(li[j])

Solution (Python):
n, m = map(int, input().split())
ans = dict.fromkeys([str(i) for i in range(1,n+1)], 0)
li = [list(map(int, input().split())) for j in range(m)]
for i in range(m):
    ans[str(li[i][0])] += 1
    ans[str(li[i][1])] += 1
for k in range(1,n+1):
    print(ans[str(k)])

Solution (Python):
N, M = map(int, input().split())

aLst = [0] * M
bLst = [0] * M

for i in range(M):
    a, b = map(int, input().split())
    aLst[i] = a
    bLst[i] = b

for i in range(1, N + 1):
    ans = aLst.count(i)
    ans += bLst.count(i)
    print(ans)

Solution (Python):
N,M=[int(x) for x in input().split()]
ans=[0]*N
for m in range(M):
  a,b=[int(x) for x in input().split()]
  ans[a-1]+=1
  ans[b-1]+=1
for a in ans:
  print(a)

Solution (Python):
 
from collections import Counter
n, m = [int(el) for el in input().split(' ')]
C = Counter()
for i in range(m):
    C.update([int(el) for el in input().split(' ')])
for i in range(n):
    print(C[i+1])

Solution (Python):
n,m = map(int,input().split())
l = []
for i in range(m):
  c1,c2 = map(int,input().split())
  l.append(c1)
  l.append(c2)
for i in range(n):
  print(l.count(i+1))

Solution (Python):
n,m = list(map(int, input().split()))
al = [0]*m; bl = [0]*m
for i in range(m):
	a,b = list(map(int, input().split()))
	al[i] = a; bl[i] = b
n_road = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
	n_road[(al[i]-1)][(bl[i]-1)] += 1
	n_road[(bl[i]-1)][(al[i]-1)] += 1
for i in range(n):
	print(sum(n_road[i]))

Solution (Python):
N, M = map(int, input().split())
cities = [0] * (N+1)
for _ in range(M):
  a, b = map(int, input().split())
  cities[a] += 1
  cities[b] += 1
for idx in range(1, N+1):
  print(cities[idx])

Solution (Python):
N, M = [int(x) for x in input().split()]
count = [0]*N
for i in range(M):
	x, y = [int(x) for x in input().split()]
	count[x-1] += 1
	count[y-1] += 1
for c in count:
	print(c)

Solution (Python):
N,M = map(int,input().split())
R = []
for i in range(M):
  a = list(map(int,input().split()))
  b = a[0]
  c = a[1]
  R.append(b)
  R.append(c)
  
for l in range(1,N+1):
  ans = []
  ans = [i for i in R if i == l ]
  print(len(ans))

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    G = [[] for _ in range(N)]
    for i in range(M):
        G[a[i]-1].append(b[i]-1)
        G[b[i]-1].append(a[i]-1)
    for i in range(N):
        print(len(G[i]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    a = [int()] * (M)  
    b = [int()] * (M)  
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
count =[0]*N

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

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

Solution (Python):
N,M = 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)

Solution (Python):
n,m = map(int,input().split())
city = []
num = [0] * n
for i in range(m):
    city.append(list(map(int,input().split())))
for i in range(m):
    for j in range(2):
            num[city[i][j] - 1] += 1
for i in num:
    print(i)

Solution (Python):
N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = []
for i in range(M):
    a[i], b[i] = map(int, input().split())
    c.append(a[i])
    c.append(b[i])

for i in range(N):
    print(c.count(i+1))

Solution (Python):
n, m = map(int, input().split())
double_dimension = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    double_dimension[a-1][b-1] += 1
    double_dimension[b-1][a-1] += 1
for i in range(n):
    print(sum(double_dimension[i]))

Solution (Python):
n, m = map(int, input().split())
double_dimension = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    double_dimension[a-1][b-1] += 1
tmp = []
for i in range(n):
    row = sum(double_dimension[i])
    column = 0
    for d in double_dimension:
        column += d[i]
    print(row + column)

Solution (Python):
import collections

[N,M]=list(map(int,input().split()))
R=[list(map(int,input().split())) for _ in range(M)]


c = collections.Counter(sum(R,[]))
keys=c.keys()
for n in range(1,N+1):
  if n not in keys:
    print(0)
  else:
    print(c[n])

Solution (Python):
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
for j in range(1,n+1):
  print(a.count(j)+b.count(j))

Solution (Python):
n, m = map(int, input().split())

count = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    count[a - 1] += 1
    count[b - 1] += 1

for i in range(n):
    print(count[i])

Solution (Python):
n,m=map(int,input().split())
roads=[]
for i in range(m):
  roads.append(input().split())
count=0
for j in range(1,n+1):
  for k in range(m):
    if int(roads[k][0])==j or int(roads[k][1])==j:
      count+=1
      
  print(count)
  count=0

Solution (Python):
N,M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

for i in range(N):
    print(x.count(i+1) + y.count(i+1))

Solution (Python):
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))

Solution (Python):
from functools import reduce

reduce(lambda a, b: a + b, [[1,2,3],[4,5,6],[7,8,9]])  
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

abflatten = sum(ab, [])



for i in range(N):
  print(abflatten.count(i+1))

Solution (Python):
N,M=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(M)])
C=[0]*N
for a in li:
  C[a[0]-1]+=1
  C[a[1]-1]+=1
for c in C:   
  print(c)

Solution (Python):
n, m = map(int, input().split())
r = {i + 1 : 0 for i in range(n)}
for i in range(m):
    a, b = map(int, input().split())
    r[a] += 1
    r[b] += 1
for i in range(n):
    print(r[i + 1])

Solution (Python):
import numpy as np

n,m = map(int,input().split())

d = [0 for i in range(n)]

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

for i in range(n):
    print(d[i])

Solution (Python):
N, M = list(map(int, input().split()))
l = []
for i in range(M):
    a, b = map(int, input().split())
    l.extend([a, b])
for j in range(1, N+1):
    print(l.count(j))

Solution (Python):
n, m = list(map(int, input().split()))
roads = [list(map(int, input().split())) for i in range(m)]
roads_in_city = [0] * n
for road in roads:
    roads_in_city[road[0] - 1] += 1
    roads_in_city[road[1] - 1] += 1
for r in roads_in_city:
    print(r)

Solution (Python):
N, M = map(int, input().split())
l=[]
for i in range(M):
  a, b = map(int,input().split())
  l.append(a)
  l.append(b)

for i in range(1, N+1):
  print(l.count(i))

Solution (Python):
c,r=map(int,input().split())

l=[]
for i in range(r):
    x,y=map(int,input().split())
    l.append(x)
    l.append(y)

for j in range(1,c+1):
    print(l.count(j))

Solution (Python):
n,m=map(int,input().split())
A=[]
B=[]
for _ in range(m):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
for i in range(n):
    print(A.count(i+1)+B.count(i+1))

Solution (Python):
N, M = map(int, input().split())
U = [[] for _ in range(N + 1)]

for _ in range(M):
    a, b = map(int, input().split())
    U[a].append(b)
    U[b].append(a)

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

Solution (Python):
N, M = map(int, input().split())
a = [0] * M
b = [0] * M

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

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

Solution (Python):
n,m = map(int,input().split())
l = []
for i in range(m):
    a,b = map(int,input().split())
    l.append(a)
    l.append(b)
l.sort()
count = 1
for i in range(n):
    print(l.count(i+1))

Solution (Python):
n, m = map(int, input().split())
c  = [0] * n

for _ in range(m):
  a, b = map(int, input().split())
  c[a-1] += 1
  c[b-1] += 1

for r in c:
  print(r)

Solution (Python):
a, b = map(int, input().split())
c = [0] * a
for i in range(b):
    d, e = map(int, input().split())
    c[d-1] += 1
    c[e-1] += 1
for i in c:
    print(i)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b, c = LI()
    if a <= c <= b:
        print("Yes")
        return
    print("No")
    return


def B():
    n, m = LI()
    e = defaultdict(int)
    for i in range(1, n + 1): e[i] = 0
    for i in range(m):
        a, b = LI()
        e[a] += 1
        e[b] += 1
    for i in e.values():
        print(i)
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

Solution (Python):
def main():
    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
    for a in ans:
        print(a)


main()

Solution (Python):
N, M = map(int, input().split())
res = [0]*N
for _ in range(M):
    a, b = map(int, input().split())
    res[a-1] += 1
    res[b-1] += 1
for _ in range(N):
    print(res[_])

Solution (Python):
def main():
    n, m = map(int, input().split())
    roads = [list(map(int, input().split())) for i in range(m)]

    for i in range(n):
        print(sum(roads, []).count(i + 1))


if __name__ == "__main__":

    main()

Solution (Python):
n,m=map(int,input().split())
l=[]
for _ in range(m):
    l+=list(map(int,input().split()))
print(*[l.count(i+1) for i in range(n)],sep='\n')

Solution (Python):
a, b = map(int, input().split())
c = [0] * a
for i in range(b):
    d, e = map(int, input().split())
    c[d-1] += 1
    c[e-1] += 1
for i in c:
    print(i)

Solution (Python):
n,m = map(int, input().split())
binary = [0 for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    binary[a-1] += 1
    binary[b-1] += 1
for i in binary:
    print(i)

Solution (Python):
n, m = map(int, input().split())
ans = []
for i in range(m):
    a, b = map(int, input().split())
    ans.append(a)
    ans.append(b)
for i in range(n):
    print(ans.count(i+1))

Solution (Python):
n,m=map(int,input().split())
x=[]
for i in range (m):
    a,b =map(int,input().split())
    x.append(a)
    x.append(b)

for i in range (n):
    cnt=0
    for j in range(m*2):
        if x[j]==i+1:
            cnt = cnt+1
    print(cnt)

Solution (Python):
from collections import defaultdict

def main():
    num, k = map(int, input().split())
    data = defaultdict(int)
    for i in range(k):
        a, b = map(int, input().split())
        data[a] += 1
        data[b] += 1

    for i in range(1, num + 1):
        print(data[i])

if __name__ == '__main__':
    main()

Solution (Python):
a,b=map(int,input().split())
c=[[int(j) for j in input().split()] for i in range(b)]
d=[0 for i in range(a)]
for i in range(b):
    d[c[i][0]-1]+=1
    d[c[i][1]-1]+=1

for i in range(a):
  print(d[i])

Solution (Python):
n, m = map(int, input().split())
ans = [0] * (n + 1)
for _ in range(m):
  a, b = map(int, input().split())
  ans[a] += 1
  ans[b] += 1
for i in ans[1:]:
  print(i)

Solution (Python):
N, M = map(int, input().split())
lst = [0] * (N + 1)
for _ in range(M):
    a, b = map(int, input().split())
    lst[a] += 1
    lst[b] += 1

for x in lst[1:]:
    print(x)

Solution (Python):
N, M = map(int, input().split())
lst = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    lst[a-1] += 1
    lst[b-1] += 1

for i in lst:
    print (i)

Solution (Python):
n, m = map(int, input().split())
road_list =[]
for i in range(m):
    road_list += list(map(int, input().split()))

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

Solution (Python):
n, m = map(int, input().split())
road_list = [list(map(int, input().split())) for i in range(m)]
road_list = [item for innerlist in road_list for item in innerlist]

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

Solution (Python):


def main(N,M,A,B):
    ct = [0]*N
    for i in range(M):
        ct[A[i]-1] += 1
        ct[B[i]-1] += 1
    for i in range(N):
        print(ct[i])
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(M):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    
    main(N,M,A,B)

Solution (Python):
n,m=map(int,input().split())
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))
l=[]
for i in range(n):
    l.append(0)

for i in range(m):
         l[ab[i][0]-1]+=1
         l[ab[i][1]-1]+=1
for i in range(n):
         print(l[i])

Solution (Python):
N, M = map(int, input().split())

A, B = [], []
for m in range(M):
    line = input().split()
    A.append(int(line[0]))
    B.append(int(line[1]))

for n in range(1, N+1):
    print(A.count(n) + B.count(n))

Solution (Python):
from collections import Counter

n, m = map(int, input().split(" "))
r = zip(*[list(map(int, input().split(" "))) for i in range(m)])
r = list(r)
c1 = dict(Counter(r[0]).most_common())
c2 = dict(Counter(r[1]).most_common())
for i in range(1, n + 1):
    print((c1[i] if i in c1 else 0) + (c2[i] if i in c2 else 0))

Solution (Python):



n,m = map(int,input().split())

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

Solution (Python):
n, m = map(int, input().split())
l = []
for i in range(m):
    l += list(map(int, input().split()))
for i in range(n):
    print(l.count(i+1))

Solution (Python):



def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [tuple(map(typ, input().split())) if m > 1 else typ(input()) for _ in range(n)]


def main():
    N, M = read_h()
    roads = read_v(M, m=2)
    cnt = [0] * N

    for a, b in roads:
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for c in cnt:
        print(c)


if __name__ == '__main__':
    main()

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

Solution (Python):
N, M = map(int, input().split())

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

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

Solution (Python):
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])

Solution (Python):
n,m=map(int,input().split())
edge=[0]*n
for _ in range(m):
    a,b=map(int,input().split())
    edge[a-1]+=1
    edge[b-1]+=1

for cnt in edge:
    print(cnt)

Solution (Python):
n, m = map(int, input().split())
x =[]
y =[]
for i in range(m):
    x1, y1 = [int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
d ={}
for i in range(1,n+1):
    d[i]=0

for i in range(m):
    d[x[i]] += 1
    d[y[i]] += 1

for i in range(1,n+1):
    print(d[i])

Solution (Python):
import numpy as np
row = input().split()
N = int(row[0])
M = int(row[1])
row2 = [input().split() for i in range(M)]
f = np.vectorize(int)
a = f(row2)
for i in range(1, N+1):
    count = 0
    for j in range(M):
        for k in range(2):
            if i == a[j][k]:
                count += 1
    print(count)

Solution (Python):
N, M = map(int, input().split())
ans = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    ans[a-1] += 1
    ans[b-1] += 1
for i in ans:
    print(i)

Solution (Python):
n,m = map(int,input().split())
l=[]
for i in range(m):
    l.extend(list(map(int,input().split())))
for i in range(1,n+1):
    print(l.count(i))

Solution (Python):
n,m = map(int,input().split())
lst = []
for i in range(m):
    a,b = map(int,input().split())
    lst.append(a)
    lst.append(b)

for j in range(1,n+1):
    print(lst.count(j))

Solution (Python):
n,m=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]

ret=[0 for _ in range(n)]
for i in range(n):  
  for ai in a:
    if i+1 in ai:
      ret[i]+=1
for i in ret:
  print(i)

Solution (Python):
n,m=map(int,input().split())
L=[]
for _ in range(m):
    a,b=map(int,input().split())
    L.append(a)
    L.append(b)
for i in range(1,n+1):
    print(L.count(i))

Solution (Python):
N,M=map(int, input().split())
result=[]
for i in range(N):
  result.append(0)
for j in range(M):
  a,b=map(int, input().split())
  result[a-1]+=1
  result[b-1]+=1
for k in range(N):
  print(result[k])

Solution (Python):
n, m = map(int, raw_input().split())
arr = [0] * (n+1)
for _ in range(m):
    a, b = map(int, raw_input().split())
    arr[a] += 1
    arr[b] += 1
for i in range(1, n+1):
    print arr[i]

Solution (Python):



N, M = map(int, input().split())
arr = [0 for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    arr[A - 1] += 1
    arr[B - 1] += 1
  
for j in arr:
    print (j)

Solution (Python):
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

for i in range(N):
    print(len(G[i]))

Solution (Python):

N, M = map(int, input().split())
ab = []
for i in range(M):
    ab.append(list(map(int, input().split())))
ans = []
for i in range(N):
    tmp = 0
    for k in range(M):
        if i+1 in ab[k]:
            tmp += 1
    ans.append(tmp)
for i in range(N):
    print(ans[i])

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
ans = [0] * N
for i in data:
    ans[i[0]-1] += 1
    ans[i[1]-1] += 1
for j in ans:
    print(j)

Solution (Python):
N, M = [int(s) for s in input().split()]

def main():
    n = [0 for _ in range(N)]
    for _ in range(M):
        a, b = [int(s) - 1 for s in input().split()]
        n[a] += 1
        n[b] += 1
    print('\n'.join(map(str,n)))

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())

city = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    city[a-1][b-1] += 1
    city[b-1][a-1] += 1

for i in range(n):
    print(sum(city[i]))

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    ret = [0] * N
    for i in range(M):
        ret[a[i] - 1] += 1
        ret[b[i] - 1] += 1
    for r in ret:
        print(r)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    a = [int()] * (M)  
    b = [int()] * (M)  
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()

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

for i in range(n):
    print(sum(r[i]))

Solution (Python):
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()
roads = defaultdict(list)

for i in range(M):
    a, b = nl()
    roads[a].append(b)
    roads[b].append(a)

for i in range(N):
    if i+1 in roads:
        print(len(roads[i+1]))
    else:
        print(0)

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

Solution (Python):
N,M = map(int,input().split())
d = {}
for i in range(1,N+1):
    d[i] = 0

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

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

Solution (Python):
def abc():
    n, m = map(int, input().split())
    d = {}
    for i in range(m):
        a, b = map(int, input().split())
        d[a] = d.get(a, 0) + 1
        d[b] = d.get(b, 0) + 1
    for i in range(1, n+1):
        print(d.get(i, 0))


abc()

Solution (Python):
from collections import defaultdict

N, M = map(int, input().split())
E = defaultdict(list)
for _ in range(M):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
for i in range(1, N+1):
    print(len(E[i]))

Solution (Python):
N, M = map(int, input().split())

dp = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    dp[a-1][b-1] += 1
    dp[b-1][a-1] += 1
for i in range(N):
    print(sum(dp[i]))

Solution (Python):
n,m = map(int,input().split())
li = [0]*(2*m)
for i in range(m):
  a,b = map(int,input().split())
  li[2*i] = a
  li[2*i + 1] = b
for i in range(n):
  print(li.count(i+1))

Solution (Python):
n,m=map(int,input().split())
roads=[]
for i in range(m):
    road=list(map(int,input().split()))
    roads+=[road]

for i in range(n):
    ans=0
    for j in range(m):
        if roads[j][0]==i+1:
            ans+=1
        elif roads[j][1]==i+1:
            ans+=1
    print(ans)

Solution (Python):
N,M=map(int,input().split())
l=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
print(*l,sep="\n")