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())
road = []
city = [0]*N
for i in range(M):
    road.append(list(map(int, input().split())))

for a, b in road:
    city[a - 1] += + 1
    city[b - 1] += + 1

for i in city:
    print(i)

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

r = [[0]*n for _ in [0]*n]

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

for r_i in r:
  print(sum(r_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 i in range(n):
    print(li[i])

Solution (Python):
n,m = map(int,input().split())
ab_list = [list(map(int,input().split())) 
           for nesya in range(m)]
city_list = [0]*n
for hoge in ab_list:
  a = hoge[0]
  b = hoge[1]
  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())
li = []
for _ in range(M):
  li += input().split()
for i in range(1,N+1):
  print(li.count(str(i)))

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

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

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = ri_()
d = [0] * N
for i in range(M):
    a, b = ri_()
    d[a - 1] += 1
    d[b - 1] += 1
for i in range(N):
    print(d[i])

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

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
dic = defaultdict(lambda: 0)

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

for i in range(1,n+1):
  if i in dic:
	  print(dic[i])
  else:
      print(0)

Solution (Python):
import numpy as np
n, m = map(int, input().split())
road = [0]*n
a = [0]*m
a = np.array(a)
b = [0]*m
b = np.array(b)
for i in range(m):
  x, y = input().split()
  a[i] = (int(x))
  b[i] = (int(y))
for i in range(m):
  road[int(a[i]) - 1] += 1
  road[int(b[i]) - 1] += 1
for i in road:
    print(i)

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)
        self.graph[dst].append(src)

    def get_nodes(self):
        return self.graph.keys()


def main():
    N, M = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(M)]
    g = Graph()
    for e in ab:
        g.add_edge(e[0], e[1])

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


if __name__ == "__main__":
    main()

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

l = [0 for _ in range(n)]

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

for p in l:
  print(p)

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

for i in range(m):
  tosi[ab[i][0]]+=1
  tosi[ab[i][1]]+=1
tosi.pop(0)
for i in tosi:
  print(i)

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

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

i=0
while i<M:
    a,b=map(int,input().split())
    ans[a]+=1
    ans[b]+=1
    i+=1

j=1
while j<=N:
    print(ans[j])
    j+=1

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

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

city = []
for i in range(n+1):
    city.append(0)

for i in range(1,n+1):
    for j in range(m):
        if i in li[j]:
            city[i] += 1
    print(city[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 x in d:
    print(x)

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

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

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

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n, m = map(int, input().split()) 
    edge = [[] * n for i in range(n)] 
    for i in range(m): 
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        edge[x].append(y)
        edge[y].append(x) 
    for i in range(n):
        print(len(edge[i]))
resolve()

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

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M = MAP()
ab = [LIST() for _ in range(M)]
cnt = [0]*N

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

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

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  
    a_b_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  
        a_b_arr.append(_)
    
    cnt = [0] * N
    for a, b in a_b_arr:
        cnt[a-1] += 1
        cnt[b-1] += 1
    
    for i in range(N):
        print(cnt[i])

Solution (Python):
from collections import defaultdict
dic = defaultdict(list)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
for i in range(1,n+1):
    print(len(dic[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(n):
    print(l.count(i+1))

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,m=MI()
lis=[[]for i in range(n)]
for i in range(m):
    a,b=MI()
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(n):
    print(len(lis[i]))

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

    towns = {}
    for i in range(n):
        towns[i] = 0

    for j in range(m):
        for k in range(2):
            towns[A[j][k] -1] += 1

    for l in range(n):
        print(towns[l])
resolve()

Solution (Python):

n,m = map(int, input().split())
xy = [map(int,input().split()) for _ in range(m)]
x,y = [list(i) for i in zip(*xy)]
l = x + y


d = {}

for i in range(1,n+1):
    d[i] =0
for i in l:
    if i not in d:
        d[i] = 0
    d[i] += 1

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

Solution (Python):
n,m=map(int,input().split())
k=[0]*n
for i 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):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
nn = [0]*n
for i in ab:
  nn[i[0]-1] += 1
  nn[i[1]-1] += 1
for i in nn:
  print(i)

Solution (Python):
N, M = map(int, input().split())
P = []
for i in range(M):
    P.append([int(k) for k in input().split()])
for t in range(N):
    cnt = 0
    for r in range(M):
        if t+1 in P[r]:
            cnt += 1
    print(cnt)

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

Solution (Python):
n, m = map(int, input().split())
cnt = [0]*(n+1)
for _ in range(m):
    i1, i2 = map(int, input().split())
    cnt[i1] += 1
    cnt[i2] += 1
print("\n".join(map(str, cnt[1:])))

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

Solution (Python):
import collections

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

a = [v[0] for v in ab]
b = [v[1] for v in ab]
a.extend(b)
c = collections.Counter(a)

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

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

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

for i in range(1,n+1):
    print(len(p[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(i) for i in ans]

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("\n".join(map(str,ans)))

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

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

c=[]
for i in range(1,N+1):
  c.append(a.count(i)+b.count(i))
  print(a.count(i)+b.count(i))

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

Solution (Python):
N, M = map(int, input().split())
lis = []
for i in range(M):
    lis += map(int, input().split())
for j in range(N):
    print(lis.count(j+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())
for i in range(n):
    print(a.count(i+1)+b.count(i+1))

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

K=[0 for j in range(N)]


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

for s in range(N):
    print(K[s])

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

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    n, m = MII()
    loads = {i: [] for i in range(n)}
    for i in range(m):
        a, b = MIIZ()
        loads[a].append(b)
        loads[b].append(b)
    for l in loads.values():
        print(len(l))

if __name__ == '__main__':
    main()

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

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

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

for g in graph:
    print(g)

Solution (Python):


n,m=map(int,input().split())
ans=[0 for _ 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 ans:
    print(i)

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

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

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

Solution (Python):
import sys
input=sys.stdin.buffer.readline
n,m=map(int,input().split())
cnt=[0]*(n+1)
for _ in range(m):
    a,b=map(int,input().split())
    cnt[a]+=1
    cnt[b]+=1
cnt.pop(0)
print(*cnt,sep="\n")

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

c = []
for _ in range(M):
  a = input().split()
  c.extend(a)
  
for i in range(1,N+1):
  print(c.count(str(i)))

Solution (Python):
import numpy as np
import sys

input = sys.stdin.readline

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 a in res:
    print(a)

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

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

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

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

Solution (Python):
N,M=(int(x) for x in input().split())
a_list=[]
b_list=[]
for i in range(M):
  a,b=(int(x) for x in input().split())
  a_list.append(a)
  b_list.append(b)
count=[0]*N
c_list=a_list+b_list
for r in c_list:
  count[r-1]+=1

[print(l) for l in count]

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

Solution (Python):
n,m = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(m)]
G = [[] for _ in range(n)]
for l in L:
    G[l[0]-1].append(l[1]-1)
    G[l[1]-1].append(l[0]-1)
for g in G:
    print(len(g))

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

for j in range(1, n+1):
    print(l[j])

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

for j in L:
    for v in j:
        d[v] += 1

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

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

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

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for i in range(M)]
    import collections
    d = collections.OrderedDict([(i, 0) for i in range(1, N+1)])
    for ab in AB:
        d[ab[0]] += 1
        d[ab[1]] += 1
    for k in d:
        print(d[k])


if '__main__' == __name__:
    resolve()

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    for i in res:
        print(i)


if __name__ == '__main__':
    resolve()

Solution (Python):
N,M=map(int,input().split())
xy = [map(int,input().split())for _ in range(M)]
x,y=[list(i) for i in zip(*xy)]
city=[0]*N
for i in range(M):
    for n in range(1,N+1):
        if x[i]==n:
            city[n-1]=city[n-1]+1
        if y[i]==n:
            city[n-1]=city[n-1]+1
for i in range(N):
    print(city[i])

Solution (Python):
N,M = map(int,input().split())
d = {x:0 for x in range(1,N+1)}
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())
L = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
for l in L:
    print(len(l))

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

Solution (Python):

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

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

    ans[a] += 1
    ans[b] += 1

for i in ans:
    print(i)

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

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


cnt_list = [0]*N

for _list in ab:
	for j in _list:
		cnt_list[j-1]+=1
for i in cnt_list:
	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(N):
  print(len([1 for x in l if x==i+1]))

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

Solution (Python):
import itertools
import collections
n,m = map(int,input().split())
A =[list(map(int,input().split())) for _ in range(m)]
B = list(itertools.chain.from_iterable(A))
S = collections.Counter(B)
for i in range(1,n+1):
    print(S[i])

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
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    path = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, readline().rstrip().split())
        path[a-1].append(b-1)
        path[b-1].append(a-1)
    for i in range(N):
        print(len(path[i]))


if __name__ == '__main__':
    main()

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

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

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 i 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):
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):

import collections

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

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

counter = collections.Counter(ab_list)
for i in range(N):
    print(counter[i + 1])

Solution (Python):
n,m = map(int,input().split())
l = []
anslist = [0]*n
while True:
  try:
    tmpa,tmpb = map(int,input().split())
    n = (tmpa,tmpb)
    l.append(n)
    
    
  except:
    break
    
for i,j in l:
  anslist[i-1] +=1
  anslist[j-1] +=1
  
for i in anslist:
  print(i)

Solution (Python):
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N, M = map(int, readline().split())
    load = [0]*N
    for _ in range(M):
        a, b = map(int, readline().split())
        load[a-1]+=1
        load[b-1]+=1
    for i in range(N):
        print(load[i])




if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
N, M = map(int,input().split())
d = defaultdict(int)
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):
from sys import stdin
import sys

[N, M] = list(map(int, stdin.readline().rstrip().split()))

a = []
for i in range(M):
    a.append(list(map(int, stdin.readline().rstrip().split())))

city = [[] for i in range(N+1)]

for i in range(M):
    [s, d] = a[i]
    city[s].append(d)
    city[d].append(s)

for i in range(1, N+1):
    if len(city[i]) >= 0:
        print(len(city[i]))

Solution (Python):
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
ans = [0]*n
for i in range(2):
    for j in range(m):
        ans[a[j][i]-1] += 1
print(*ans, sep='\n')

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):
n,m = map(int, input().split())

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

Solution (Python):
import collections

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

counter = collections.Counter(li)
for i in range(N):
    print(counter[i + 1]) if i + 1 in counter else print(0)

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 main():
    N, M = map(int, input().split())
    road = [0] * N
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, input().split())
        road[a] += 1
        road[b] += 1
    print('\n'.join(map(str, road)))


if __name__ == '__main__':
    main()

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

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

for line in input_lines:
    map_list[line[0]][line[1]]+=1
    map_list[line[1]][line[0]]+=1

for li in map_list:
    print(sum(li))

Solution (Python):
N, M = map(int, input().split())
roads_count = [0 for i in range(N)]
city = [[int(i) for i in input().split()] for j in range(M)]

for road in city:
    roads_count[road[0]-1] += 1
    roads_count[road[1]-1] += 1

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

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

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

Solution (Python):









import numpy as np






N,M = map(int,input().split())
ans = np.zeros(N+1,dtype="int64")
for i in range(M):
    a, b = map(int,input().split())
    ans[a] += 1
    ans[b] += 1

print(*ans[1:],sep="\n")

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

for i, j in a:
    ans[i-1] += 1
    ans[j-1] += 1

for ai in ans:
    print(ai)

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

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

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

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

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

for x in d:
    print(x)

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

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

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

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