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

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 = [int(item) for item in input().split()]
count = [0] * n
for i in range(m):
    a, b = [int(item) for item in input().split()]
    count[a-1] += 1
    count[b-1] += 1
for item in count:
    print(item)

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 range(n):
  print(ans[i])

Solution (Python):
n, m = map(int, input().split())
d = dict.fromkeys(list(range(1, n + 1)), 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):
N,M=map(int,input().split())
A=[]
for i in range(M):
    A.extend(sorted(list(map(int,input().split()))))
for j in range(1,N+1):
    print(A.count(j))

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N,M = (int(_) for _ in input().split())
    a = []
    b = []
    ans = [0]*(N+1)
    
    
    for i in range(M):
        s1,s2 = (int(_) for _ in input().split())
        a.append(s1)
        b.append(s2)

    for i in range(M):
        ans[a[i]] +=1
        ans[b[i]] +=1
    print('\n'.join(str(_) for _ in ans[1:]))
    
if __name__ == '__main__':
    main()

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

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

for i in a:
    print(i)

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

maps = {i:0 for i in range(1, N+1)}

for load in ls:
    maps[load[0]] += 1
    maps[load[1]] += 1

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

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

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

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

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

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

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

nodes = [0] * N

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

for i in range(0,N):
    print(nodes[i])

Solution (Python):
N, M = map(int, input().split())
a = [0 for i in range(M)]
b = [0 for i in range(M)]
ans = [0 for i in range(N)]
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):
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n, m = nm()
ab = [nl() for i in range(m)]
ans = [0 for i in range(n)]
for i in range(m):
    ans[ab[i][0] - 1] += 1
    ans[ab[i][1] - 1] += 1
for i in range(n):
    print(ans[i])

Solution (Python):
N, M = map(int, input().rstrip().split())
ab = [list(map(int, input().rstrip().split())) for _ in range(M)]
count = [[0]*N for _ in range(N)]
for road in ab:
    count[road[0]-1][road[1]-1] += 1
    count[road[1]-1][road[0]-1] += 1
for i in range(N):
    print(sum(count[i]))

Solution (Python):
from collections import OrderedDict
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
X = OrderedDict([(i + 1, []) for i in range(N)])
for a, b in L:
    X[a].append(b)
    X[b].append(a)
for _, x in X.items():
    print(len(x))

Solution (Python):
import numpy as np
n, m = map(int, raw_input().split())
arr = np.zeros(n, dtype=int)

for i in range(m):
	a = map(int, raw_input().split())
	arr[a[0]-1] += 1
	arr[a[1]-1] += 1

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

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

Solution (Python):
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    d = defaultdict(lambda: 0)
    N, M = map(int, input().split())
    for _ in range(M):
        a, b = map(int, input().split())
        d[a] += 1
        d[b] += 1

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


if __name__ == '__main__':
    main()

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

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

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

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

for a in count:
    print(a)

Solution (Python):
N, M = map(int, input().split())
R = [tuple(map(int, input().split())) for _ in range(M)]
C = [[] for _ in range(N)]
for r in R:
	C[r[0]-1].append(r[1]-1)
	C[r[1]-1].append(r[0]-1)
for c in C:
	print(len(c))

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

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())
city = [0] * n

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

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

Solution (Python):
from numpy import zeros
n, m = map(int, input().split())
ci = zeros(n)
for i in range(m):
    f, t = map(int, input().split())
    ci[f-1] += 1
    ci[t-1] += 1
for i in range(n):
    print(int(ci[i]))

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

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(1,n+1):
    print(X.count(i))

Solution (Python):
n,m=map(int,input().split())
ans=[0for i in range(n)]
for i in range(m):
  a,b=map(int,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())
list = [] 
for i in range(n+1):
    list.append(0)
for i in range(m):
    load1,load2 = map(int,input().split())
    list[load1] = list[load1]+1
    list[load2] = list[load2]+1
for i in range(1,n+1):
    print(list[i])

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
a,b,c = LI()
if a <= c <= b:
    print("Yes")
else:
    print("No")
"""

n,m = LI()
d = [0 for i in range(n+1)]
for i in range(m):
    a,b = LI()
    d[a] += 1
    d[b] += 1
for i in range(1,n+1):
    print(d[i])



"""
def bellman_ford(start):
    dist = [float("inf") for i in range(n)]
    dist[start] = 0
    for i in range(n-1):
        update = False
        for j, k, l in adj:
                if dist[k] > dist[j] + l:
                    dist[k] = dist[j] + l
                    update = True
        if not update:
            break
    negative = [False for i in range(n)]
    for j, k, l in adj:
        if dist[k] > dist[j] + l:
            dist[k] = dist[j] + l
            negative[k] = True
    return dist,negative[n-1]
n,m = LI()
adj = []
for i in range(m):
    a,b,c = LI()
    a -= 1
    b -= 1
    adj.append([a,b,-c])
d,ne = bellman_ford(0)
if ne:
    print("inf")
else:
    print(-d[-1])
"""

Solution (Python):
import collections

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

c = collections.Counter(a + b)

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

Solution (Python):
def counting_roads(N: int, M: int, roads: list)->list:
    d = {i: 0 for i in range(N)}
    for u, v in roads:
        d[u-1] += 1
        d[v-1] += 1

    return d.values()


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    roads = [tuple(map(int, input().split())) for _ in range(M)]
    ans = counting_roads(N, M, roads)
    print('\n'.join(map(str, ans)))

Solution (Python):
import collections
N,M=map(int,input().split())
road=[]
for i in range(M):
    road.extend([int(i) for i in input().split()])
roads=collections.Counter(road)
[print(roads[i+1]) for i in range(N)]

Solution (Python):
n, m = [int(_) for _ in input().split()]
ans = [0]*(n+1)

for _ in range(m):
    a, b = [int(__) for __ in 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())
city = [0 for i in range(N)]
for i in range(M):
  start, end = map(int, input().split())
  city[start-1] += 1
  city[end-1] += 1

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

Solution (Python):
N,M = map(int,input().split())
bucket = {}
for i in range(N):
  bucket[i] = 0
for m in range(M):
  tempa,tempb = map(int,input().split())
  bucket[tempa-1] += 1
  bucket[tempb-1] += 1
for i in range(N):
  print(bucket[i])

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

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

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

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

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

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

[print(result[i]) for i in range(N)]

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
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())
abn = [map(int, input().split()) for _ in range(M)]

cs = [0] * N
for a, b in abn:
    cs[a-1] += 1
    cs[b-1] += 1

for c in cs:
    print(c)

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

for j in range(n):
  a = 0
  for k in range(m):
    a = a + listA[k].count(j+1)
  print(a)

Solution (Python):

N,M= map(int,input().split())
f = [0] * (N + 20)
for i in range(M):
    x,y = map(int,input().split())
    f[x]+=1
    f[y]+=1
for i in range(1,N+1):
    print(f[i])

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

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

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

Solution (Python):
n,m=map(int,input().split())
x=[0 for i 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 = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

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

for k in c:
    print(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())
l=[]
for i in range(n):
  l.append(0)
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):
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))))

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return



N, M = 0, 0
A, B = [], []


def set_inputs():
    global N, M, A, B
    N, M = get_list_of_int()
    get_data(M, A=int, B=int)
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    s = "".join(list(map(lambda x: chr(ord("A") + x), A + B)))
    for i in range(N):
        print(s.count(chr(ord("A") + i + 1)))
    return


if __name__ == '__main__':
    main()

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

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 i in range(M)]
ans=[0 for i in range(N)]
for i in range(M):
    A=ab[i][0]-1
    B=ab[i][1]-1
    ans[A]+=1
    ans[B]+=1
for i in range(N):
    print(ans[i])

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

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

for i in range(n):
	c = 0
	for j in range(m):
		c += l[j].count(i+1)
		
	print(c)

Solution (Python):
from collections import defaultdict
class Graph(object):
    
    def __init__(self):
        self.graph = defaultdict(list)
    def __len__(self):
        return len(self.graph)
    def add_edge(self, src, dst):
        self.graph[src].append(dst)
N,M = map(int,input().split())
loapdic = {}
ga = Graph()
for i in range(M):
    a,b = map(int,input().split())
    ga.add_edge(a, b)
    ga.add_edge(b, a)
for n in range(1,N+1):
    print(len(ga.graph[n]))

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

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

for i in range(1, n+1):
    ans = 0
    for x, y in bridge:
        if x == i or y == i:
            ans += 1
    print(ans)

Solution (Python):
from collections import defaultdict


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

d = defaultdict(int)

for v in al:
    d[v] += 1

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

Solution (Python):
N,M = map(int,input().split())
road = [0] * N
for _ in range(M):
    C,D = map(int,input().split())
    road[C-1] += 1
    road[D-1] += 1
for r in road:
    print(r)

Solution (Python):
n,m = (int(i) for i in input().split())
e = [[int(i)-1 for i in input().split()] for i in range(m)]

count = [0]*n

for x in e:
    for y in x:
        count[y] += 1

for x in count:
    print(x)

Solution (Python):
N,M = map(int,input().split(' '))
nodes = []
for i in range(M):
  for j in list(map(int,input().split(' '))):
    nodes.append(j)
for i in range(N):
  print(nodes.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 c:
  print(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)
for i in range(1,N+1):
    print(L.count(i))

Solution (Python):
N, M = map(int, input().split())
alist = [0] * M
blist = [0] * M
for i in range(M):
    alist[i], blist[i] = map(int, input().split())
city = list(range(1,N+1))
judge = [0] * N
count = dict(zip(city,judge))
for a,b in zip(alist,blist):
    count[a] += 1
    count[b] += 1
for c in count:
    print(count[c])

Solution (Python):
def main():
    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 range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
t = np.ravel(s)

for i in range(1,n+1):
    print(np.sum(t == i))

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

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

for i in count:
    print(i)

Solution (Python):
from itertools import chain
n,m = map(int,input().split())
ab_list = [list(map(int, input().split())) for _ in range(m)]
tmp_list = sorted(list(chain(*ab_list)))
tmp_dic = {}
for i in range(1,n+1):
    tmp_dic[i]=0
for val in tmp_list:
    tmp_dic[val] += 1
for k,v in tmp_dic.items():
    print(v)

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

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

Solution (Python):
N, M = [int(x) for x in input().split()]
L = [[int (y) for y in input().split()] for _ in range(M)]
L = sum(L, [])

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

Solution (Python):
import numpy as np

N, M = [int(x) for x in input().split()]
L = [[int (y) for y in input().split()] for _ in range(M)]
L = sum(L, [])

for i in np.arange(1, N+1):
    print(L.count(i))

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

ans = []
for i in range(N):
    n = 0
    for j in range(M):
        a, b = ab_s[j]
        if a == (i + 1) or b == (i + 1):
            n += 1
    ans.append(n)

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

Solution (Python):
n,_,*r=map(int,open(0).read().split());print(*map(r.count,range(1,n+1)))

Solution (Python):
import itertools
n,m=map(int,input().split())
k = []
[k.append(z[0]) for _ in range(m)  for z in itertools.permutations(input().split())]
for nn in range(1, n+1):
  print(k.count(str(nn)))

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

Solution (Python):



"""
Counting Roads
"""

def answer():
    """
    答えをN行で出力する。
    """
    N, M = map(int, input().split())
    load = []
    for _ in range(M):
        load += list(map(int, input().split()))

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


def main():
    """
    処理を実行する。
    """
    answer()

if __name__ == '__main__':
    main()

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

Solution (Python):
n,m = 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 = countDic.keys()
ks = sorted(ks)[1:]

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    adj[a].append(b)
    adj[b].append(a)

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

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):
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 i in range(n):
    print(ans[i])

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 = list(map(int, input().split()))
roads = [list(map(int, input().split())) for i in range(m)]





for i in range(1, n + 1):
    counter = 0
    for road in roads:
        if i in road:
            counter += 1
    print(counter)

Solution (Python):
""" AtCoder """

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

ans = [0 for _ in range(N)]

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

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

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

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

for i in range(M):
  s = input().split()
  a = s[0]
  b = s[1]
  dic[a] += 1
  dic[b] += 1
   
for i in range(N):
  tmp = str(i+1)
  print(dic[tmp])

Solution (Python):
N,M=map(int,input().split())
a,b=[],[]                       
for i in range(M):
  x,y=input().split()
  a.append(x)
  b.append(y)
for j in range(1,N+1):          
  e1=a.count("{}".format(j))
  e2=b.count("{}".format(j))
  print(e1+e2)

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

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

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

Solution (Python):

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

Solution (Python):
from collections import Counter

N, M = list(map(int, input().split()))
ab = []

for i in range(M):
    ab.extend(list(map(int, input().split())))
ab = Counter(ab)

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

Solution (Python):

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("yes")
    else:print("no")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())



n,m= (int(i) for i in input().split())      










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

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

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 = [input().split() for j in range(1) for i in range(m)]
b = sum(a, [])

L = []

for i in range(1, n+1):
    L.append(b.count(str(i)))

for i in L:
    print(i)

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

Solution (Python):
N, M = map(int, input().split())
x = [ list(map(int, input().split())) for i in range(M)]
bucket = {str(i):0 for i in range(1, N+1)}
for i in x:
    for p in i:
        bucket[str(p)] += 1
for i in range(1, N+1):
    print(bucket[str(i)])

Solution (Python):
n,m = map(int, input().split())
roads = [list(map(lambda x:int(x)-1, input().split())) for _ in range(m)]

arr = [0]*n
for r in roads:
    arr[r[0]] +=1
    arr[r[1]] +=1

for a in arr:
    print(a)

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

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

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

for i in range(len(_input)):
    counters[_input[i][0]-1] += 1
    counters[_input[i][1]-1] += 1

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

Solution (Python):
n,_,*r=map(int,open(0).read().split())
for i in range(n):print(r.count(-~i))

Solution (Python):
n,_,*r=map(int,open(0).read().split())
for i in range(n):print(r.count(-~i))

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

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

Solution (Python):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
d = {i:0 for i in range(n)}
for a, b in ab:
    d[a-1] += 1
    d[b-1] += 1
for i in range(n):
    print(d[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)

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

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

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

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

Solution (Python):
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 k in range(n):
    print(x[k])

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

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

for i in range(N):
  num = 0
  for j in range(M):
    if a[j] == i or b[j] == i:
      num += 1
  print(num)

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

for i in range(1, len(c)):
    print(c[i])

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

[print(x) for x in ans]

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

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