//package codeforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class D {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

    String next() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    final int MOD = 1000 * 1000 * 1000 + 7;
    int sum(int a, int b) {
        a += b;
        return a >= MOD ? a - MOD : a;
    }

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        final int n = nextInt();
        int m = nextInt();
        int[] from = new int[m];
        int[] to = new int[m];
        for(int i = 0; i < m; i++) {
            from[i] = nextInt();
            to[i] = nextInt();
        }
        int ans = solve(n, m, from, to);
        writer.println(ans);
        writer.close();
    }

    private int solve(final int n, int m, int[] from, int[] to) {
        final List<List<Integer>> g = new ArrayList<>();
        final List<List<Integer>> rg = new ArrayList<>();
        for(int i = 0; i <= n; i++) {
            g.add(new ArrayList<Integer>());
            rg.add(new ArrayList<Integer>());
        }
        int[] c = new int[n + 1];
        int[] loop = new int[n + 1];
        for(int i = 0; i < m; i++) {
            int u = from[i];
            int v = to[i];
            g.get(u).add(v);
            rg.get(v).add(u);
            c[u]++;
            c[v]++;
            if(u == v) {
                loop[u]++;
            }
        }
        class Utils {
            int[] prev = new int[n + 1];
 ... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?