Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.util.*;

public class Template implements Runnable {
    private void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        boolean[][] g = new boolean[n][n];
        for (int i = 0; i < m; ++i) {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            g[a][b] = true;
            g[b][a] = true;
        }
        /*for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                g[i][j] = true;*/
        long[] am = new long[n + 1];
        long[][] ways = new long[1 << n][n];
        for (int start = 0; start < n; ++start) {
            for (int mask = 0; mask < (1 << (n - start)); ++mask)
                for (int last = start; last < n; ++last) {
                    ways[mask][last - start] = 0;
                }
            ways[1][0] = 1;
            for (int mask = 0; mask < (1 << (n - start)); ++mask) {
                int cnt = 0;
                int tmp = mask;
                while (tmp > 0) {
                    ++cnt;
                    tmp = tmp & (tmp - 1);
                }
                for (int last = start; last < n; ++last)
                    if (ways[mask][last - start] > 0) {
                        long amm = ways[mask][last - start]; 
                        for (int i = start; i < n; ++i)
                            if ((mask & (1 << (i - start))) == 0 && g[last][i]) {
                                ways[mask | (1 << (i - start))][i - start] += amm;
                            }
                        if (g[last][start])
                            am[cnt] += ways[mask][last - start];
                    }
            }
        }
        long res = 0;
        for (int cnt = 3; cnt <= n; ++cnt) {
            if (am[cnt] % (2) != 0)
                throw new RuntimeException();
            res += am[cnt] / (2);
        }
        writer.println(res);
    }


    public static void main(String[] args) {
        new Template().run();
    }

    BufferedReader reader;
   ... Complexity: