// Arup Guha
// 2/12/2021
// Solution to 2021 USACO January Silver Problem: Dance Mooves
 
import java.util.*;
import java.io.*;

public class dancemoves {

	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		
		int n = Integer.parseInt(tok.nextToken());
		int k = Integer.parseInt(tok.nextToken());

		// locs[i] stores all the locations the cow in location i visits in the first k moves.
		HashSet<Integer>[] locs = new HashSet[n];
		for (int i=0; i<n; i++) {
			locs[i] = new HashSet<Integer>();
			locs[i].add(i);
		}
		
		// This will eventually store the effective permutation of the first k da
		int[] perm = new int[n];
		for (int i=0; i<n; i++) perm[i] = i;
		
		// Read and do the swaps.
		for (int i=0; i<k; i++) {
			
			// Get the pair.
			tok = new StringTokenizer(stdin.readLine());
			int u = Integer.parseInt(tok.nextToken()) - 1;
			int v = Integer.parseInt(tok.nextToken()) - 1;
			
			// Swap them and add the new locations these two items get to.
			int valU = perm[u];
			int valV = perm[v];
			locs[perm[v]].add(u);
			locs[perm[u]].add(v);
			perm[u] = valV;
			perm[v] = valU;
		}
		
		// cycle[i] will store which cycle item i is in.
		int[] cycle = new int[n];
		Arrays.fill(cycle, -1);
		
		// cycleRes[id] will store how many items total cycle # id touches. 
		int[] cycleRes = new int[n];
		
		// To label our cycles.
		int id = 0;
		
		// Go to each item.
		for (int i=0; i<n; i++) {
			if (cycle[i] != -1) continue;
			
			// The items i already hits in a single cycle.
			HashSet<Integer> tmp = new HashSet<Integer>();
			for (Integer x: locs[i]) tmp.add(x);
			
			// Note our new cycle.
			cycle[i] = id;
			int curIdx = perm[i];
			
			// Go through the cycle.
			while (curIdx != i) {
				
				// Add this item to this cycle and add all of the places it goes to our hashset.
				// We can use an amortized analysis to show that all of these in total won't add up to be too crazy...
				// It's because only a limited # of swaps occur total...
				cycle[curIdx] = id;
				for (Integer x: locs[curIdx]) tmp.add(x);
				curIdx = perm[curIdx];
			}
			
			// This is the answer for all numbers in this cycle.
			cycleRes[id] = tmp.size();
			id++;
		}
		
		// We build and output the answer and use cycleRes as a lookup table.
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<n; i++)
			sb.append(cycleRes[cycle[i]]+"\n");
		System.out.print(sb);
	}
}