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())

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())
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)

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

from collections import defaultdict
d = defaultdict(list)
for i in range(len(ab)):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    d[a].append(b)
    d[b].append(a)

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

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

for i in range(N):
  dic[i+1] = 0

for i in range(M):
  a,b = map(int,input().split())
  dic[a] += 1
  dic[b] += 1
output = dic.values()
for item in output:
  print(item)

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

Solution (Python):


def main()->None:
    N, M = map(int, input().split())
    range_M = range(M)
    ab = []
    for i in range_M:
        a, b = map(int, input().split())
        ab.append(a)
        ab.append(b)
    range_N = range(N)
    for i in range_N:
        print(ab.count(i+1))
    
if __name__ == "__main__":
    main()

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

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

ls_ans = [0]*n

for i in range(n):
    for j in range(m):
        if i+1 in ls_ab[j]:
            ls_ans[i] += 1

for k in range(n):
    print(ls_ans[k])

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(n):
    k=0
    for j in range(2*m):
        if i+1==l[j]:
            k+=1
    print(k)

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


for i in range(1, n+1):
    ans = 0
    for j in street:
        ans += j.count(i)
    print(ans)

Solution (Python):
from collections import defaultdict


def main():
    N, M, *AB = map(int, open(0).read().split())
    cnt = defaultdict(int)
    for a, b in zip(*[iter(AB)] * 2):
        cnt[a] += 1
        cnt[b] += 1
    ans = []
    for i in range(1, N + 1):
        ans.append(cnt[i])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
roads = [0] * n
[exec("roads[%d] += 1; roads[%d] += 1" % tuple(map(lambda c: int(c) - 1, input().split()))) for _ in range(m)]
print(*roads, sep="\n", end="")

Solution (Python):
NM = list(map(int,input().split()))
N=NM[0]
M=NM[1]
road=[]

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

for j in range(1,N+1):
    road.append(x.count(j)+y.count(j))
    road[j-1]=str(road[j-1])

print('\n'.join(road))

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

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

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

clst = [lst.count(i) for i in range(1, n + 1)]
print(*clst,sep='\n')

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 d:
    print(i)

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

d = []
for i in range(m):
    a, b = 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)

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

Solution (Python):
n,m=list(map(int,input().split()))
lists=[]
for i in range(n):
  lists.append(0)
for i in range(m):
  am,bm=list(map(int,input().split()))
  lists[am-1]+=1
  lists[bm-1]+=1
for i in range(n):
  print(lists[i])

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

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

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

for c in count:
    print(c)

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

cnt = [0 for i in range(N)]
for i in range(M):
  x,y = map(int,input().split())
  ab.append(x)
  ab.append(y)

for i in range(N):
  cnt[i] = ab.count(i+1)

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

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

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

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

for i in range(1, n+1):
  for j in range(m):
    if a[j] == i:
      cnt += 1
    if b[j] == i:
      cnt += 1
  print(cnt)
  cnt = 0

Solution (Python):


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


for _ in range(M):
    a,b=list(map(int,input().split(" ")))

    T[a-1]+=1
    T[b-1]+=1


for t in T:
    print(t)

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

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

Solution (Python):
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    lin[i[0]-1] +=1
    lin[i[1]-1] += 1

for i in lin:
    print(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(1,n+1):
    print(l.count(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(1, n+1):
  print(l.count(i))

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

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

l=[list(map(int,input().split())) for i in range(m)]




l = sum(l,[])



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

Solution (Python):
N,M = (int(i) for i in input().split())
roads = []
for i in range(M):
    X,Y = (int(i) for i in input().split())
    roads.append(X)
    roads.append(Y)
    
for i in range(N):
    ans = roads.count(i+1)
    print(ans)

Solution (Python):

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

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

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

for t in towns:
  print(t)

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7


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

Ans = [0]*N
for a,b in AB:
    Ans[a-1] += 1
    Ans[b-1] += 1

for ans in Ans:
    print(ans)

Solution (Python):
N,M = map(int,input().split())
dic = {}
for i in range(1,N+1):
    dic[i] = 0
for i in range(M):
    a,b = map(int,input().split())
    dic[a] += 1
    dic[b] += 1
for key,value in dic.items():
    print(value)

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

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

for i in road_list:
    print(i)

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

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

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

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

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

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

for i in range(len(ab)):
    x, y = ab[i]
    town[x - 1] += 1
    town[y - 1] += 1

print("\n".join(map(str, town)))

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

for town in towns:
    print(town)

Solution (Python):
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
ans=[0]*n
for i in range(m):
    ans[l[i][0]-1]+=1
    ans[l[i][1]-1]+=1
print(*ans,sep='\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())
loute = a + b
for i in range(n) :
    print(loute.count(i + 1))

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)
    
B = [0 for _ in range(N)]
for i in range(2*M):
    B[L[i]-1] = B[L[i]-1] + 1

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

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

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())
ans=[0]*n
for j in range(m):
    ans[a[j]-1]+=1
    ans[b[j]-1]+=1

for k in range(n):
    print(ans[k])

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

Solution (Python):
def main(n, m, a_b):
    road = [list() for n in range(n)]

    for a, b in a_b:
        road[a - 1].append(b)
        road[b - 1].append(a)

    for l in road:
        print(len(l))


if __name__ == "__main__":
    n, m = map(int, input().split(" "))
    a_b = [list(map(int, input().split())) for _ in range(m)]

    main(n, m, a_b)

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

tmp = []
for i in range(M):
    tmp.append(A[i][0])
    tmp.append(A[i][1])

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

Solution (Python):
n, m = map(int, input().split())
G = [ [] for _ in range(n+1) ]
for _ in range(m):
  a, b = map(int, input().split())
  G[a].append(b)
  G[b].append(a)
for i in G[1:]:
  print(len(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 j in range(1, n +1):
    print(ans.count(j))

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

path_dict = {n_i:[] for n_i in range(1, n+1)}

for _ in range(m):
  a, b = map(int, input().split())
  path_dict[a].append(b)
  path_dict[b].append(a)
  
for n_i in range(1, n+1):
  print(len(path_dict[n_i]))

Solution (Python):
N, M = map(int, input().split())
R = list()
for i in range(N):
  R.append(0)
for i in range(M):
  c1, c2 = map(int, input().split())
  R[c1-1] += 1
  R[c2-1] += 1
for i in range(N):
  print(R[i])

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

for i in range(M):
  for j in range(2):
    ans[l[i][j]-1] += 1

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

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

Solution (Python):
N, M = map(int, input().split())
g = [[] for _ in range(N)]
for _ 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):
def examB():
    N, M =LI()
    ans = [0]*N
    for i in range(M):
        a, b = LI()
        ans[a-1] +=1
        ans[b-1] +=1
    for v in ans:
        print(v)

import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

for _ in range(m):
    a, b = map(int, input().split())
    ls.append(a)
    ls.append(b)

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

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

Solution (Python):

n, m = [int(s) for s in input().split()]

a = []
b = []

for _ in range(m):
    tmp = [int(s) for s in input().split()]
    a.append(tmp[0])
    b.append(tmp[1])

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

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

city_list = [0 for i in range(N)]

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

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

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    roads = list(map(string_to_int, inputs))
    towns = {i+1: [] for i in range(N)}

    for r in roads:
        towns[r[0]].append(r[1])
        towns[r[1]].append(r[0])
    ret = []

    for t in sorted(towns.keys()):
        ret.append(len(towns[t]))
    return ret


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(M))
    for r in ret:
        print(r)

Solution (Python):
N, M = map(int, input().split())
A = ",".join([str(input().replace(" ",",")) for i in range(M)])
A= A.split(",")
A_list=[int(i) for i in A]
for i in range(1,N+1):
    print(A_list.count(i))

Solution (Python):
num = list(map(int, input().split(' ')))
city = num[0]
road = num[1]
city_road = []
for i in range(road):
    city_road.extend(list(map(int, input().split(' '))))

for i in range(city):
    print(city_road.count(i+1))

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
res = [[0] * n for i in range(n)]
for i in range(m):
    a,b = inpl()
    res[a-1][b-1] += 1
    res[b-1][a-1] += 1
for i in range(n):
    print(sum(res[i]))

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

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

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

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 j in range(1,n+1):
  print(l.count(j))

Solution (Python):
N, M = map(int, input().split())
ablist = [tuple(map(int, input().split())) for _ in range(M)]
city_list = [0] * N

for a, b in ablist:
    city_list[a - 1] += 1
    city_list[b - 1] += 1

for city in city_list:
    print(city)

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

for _ in range(M):
    ai, bi = input().split()
    a.append(ai)
    b.append(bi)

for i in range(1, N + 1):
    print(a.count(str(i)) + b.count(str(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())

list = a + b

for i in range(n):
    print(list.count(i + 1))

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

res = []
for _ in range(m):
    res += [int(x) for x in input().split()]

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

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

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

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

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

for i in range(n):
    cnt = 0
    for j in range(n):
        cnt += ab[i][j]
    print(cnt)

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

for i in L:
    print(i)

Solution (Python):
import collections
N,M = map(int,input().split())
mat = [list(map(int,input().split())) for i in range(M)]
tmp = []
for i in range(M):
    tmp = tmp + mat[i]
ans = collections.Counter(tmp)
for j in range(N):
    print(ans[j+1])

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

Solution (Python):
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 _ans in ans:
    print(_ans)

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

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

path_cnt = [0] * (N+1)

for i in range(M):
    path_cnt[ab[i][0]] += 1
    path_cnt[ab[i][1]] += 1

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

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

def countList(lst, x):
    count = 0
    for i in range(len(lst)):
        if x in lst[i]:
            count += 1
    return count

for i in range(1, n + 1):
    print(countList(a_b, i))

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

    
ans=[]
for i in range(n):
    ans.append(s1.count(i+1))

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

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

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

for i in range(N):
  num = i+1
  count = 0
  for a, b in paths:
    if a == num or b == num:
      count += 1
  print(count)

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

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

for r in road:
    print(r)

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

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

Solution (Python):
N,M = map(int,input().split())
G = {}
for _ in range(M):
    a,b = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(b)
for i in range(1,N+1):
    if i in G:
    	print(len(G[i]))
    else:
        print(0)

Solution (Python):
N,M = map(int, input().split())
ans = [0]*N
for i in range(0, 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())
road = [0] * n
for i in range(m):
	a,b = map(int,input().split())
	road[a-1] = road[a-1] + 1
	road[b-1] = road[b-1] + 1

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

Solution (Python):

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N,M = nm()
G = [[] for _ in range(N)]

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

for g in G:
    print(len(g))

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 x in ans:
  print(x)

Solution (Python):
N,M = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
for i in range(M):
    a,b = map(int, input().split())
    d[a] += 1
    d[b] += 1

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

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

Solution (Python):

n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
list = {i:0 for i in range(1,n+1)}
for i in ab:
  list[i[0]] += 1
  list[i[1]] += 1
for j in list.values():
  print(j)

Solution (Python):
n, m = map(int, input().split())
points = [list(map(int, input().split())) for _ in range(m)]
city = {}
city = {i:0 for i in range(1, n+1)}
for point in points:
  city[point[0]] += 1
  city[point[1]] += 1
for i in city.values():
  print(i)

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

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

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

for c in range(M):
    R[ab[c][0]-1] += 1
    R[ab[c][1]-1] += 1
for c in range(N):
    print(R[c])

Solution (Python):
N,M=map(int,input().split())
list=[[] for j in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  list[a-1]+="Y"
  list[b-1]+="Y"
for i in range(N):
  print(len(list[i]))

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

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

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

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

for _ in c:
    print(_)

Solution (Python):

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

for c in city:
    print(c)

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

roads=[[str(s) for s in input().split()] for m in range(M)]

ans={}

for m in range(M):
  for road in roads[m]:
    if road in ans:
      ans[road]+=1
    else:
      ans[road]=1

for n in range(N):
  if str(n+1) in ans:
    print(ans[str(n+1)])
  else:
    print(0)

Solution (Python):
N, M = map(int,input().split())
loads = [list(map(int, input().split())) for _ in range(M)]
dic = {i+1:0 for i in range(N)}
for load in loads:
    dic[load[0]] += 1
    dic[load[1]] += 1
for a in dic.values():
    print(a)

Solution (Python):
import collections as coll
n,m=map(int,input().split())
road=coll.defaultdict(list)
for _ in range(m):
    a,b=map(int,input().split())
    road[a].append(b)
    road[b].append(a)
for i in range(1,n+1): print(len(road[i]))

Solution (Python):
import collections
N,M=map(int,input().split())
table=collections.defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  table[a]+=1
  table[b]+=1
for i in range(1,N+1):
  print(table[i])

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

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

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

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] = ans[a-1]+1
  ans[b-1] = ans[b-1]+1
[print(i) for i in ans]

Solution (Python):
import sys
imput=sys.stdin.readline
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()
for j in range(1,n+1):
    print(l.count(j))

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

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

for road in roads:
    print(road)

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

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

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

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

Solution (Python):
from collections import Counter
N,M=map(int,input().split())
d=Counter((' '.join([input() for m in range(M)])).split(' '))
for n in range(N):
    print(d[str(n+1)])

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    d = collections.defaultdict(list)
    n, m = list(map(int, input().rstrip('\n').split()))
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        d[a] += [1]
        d[b] += [1]
    for i in range(1, n + 1):
        print(sum(d[i]))


if __name__ == '__main__':
    slove()

Solution (Python):
n, m = map(int, input().split())
s = []
u = []

for i in range(m):
    a, b = map(int, input().split())
    s.append(a)
    s.append(b)

for i in range(1, n+1):
    t = [x for x, y in enumerate(s) if y == i]
    t = len(t)
    u.append(t)

for i in u:
    print(i)

Solution (Python):
N, M = map(int, input().split())
count = [0 for _ in range(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())
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())
a=[];b=[]
for i in  range(m):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
for i in range(n):
    print(a.count(i+1)+b.count(i+1))

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

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

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

for i in road:
    print(i)

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

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