As Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That is, the direct link between clues A and B and the direct link between clues B and A is the same thing. No more than one direct link can exist between two clues.

Of course Sherlock is able to find direct links between all clues. But it will take too much time and the criminals can use this extra time to hide. To solve the crime, Sherlock needs each clue to be linked to all other clues (maybe not directly, via some other clues). Clues A and B are considered linked either if there is a direct link between them or if there is a direct link between A and some other clue C which is linked to B. 

Sherlock Holmes counted the minimum number of additional direct links that he needs to find to solve the crime. As it turns out, it equals T.

Please count the number of different ways to find exactly T direct links between the clues so that the crime is solved in the end. Two ways to find direct links are considered different if there exist two clues which have a direct link in one way and do not have a direct link in the other way. 

As the number of different ways can turn out rather big, print it modulo k.

Input

The first line contains three space-separated integers n, m, k (1 ≤ n ≤ 105, 0 ≤ m ≤ 105, 1 ≤ k ≤ 109) — the number of clues, the number of direct clue links that Holmes has already found and the divisor for the modulo operation.

Each of next m lines contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b), that represent a direct link between clues. It is guaranteed that any two clues are linked by no more than one direct link. Note that the direct links between the clues are mutual.

Output

Print the single number — the answer to the problem modulo k.

Examples

Input

2 0 1000000000


Output

1


Input

3 0 100


Output

3


Input

4 1 1000000000
1 4


Output

8

Note

The first sample only has two clues and Sherlock hasn't found any direct link between them yet. The only way to solve the crime is to find the link.

The second sample has three clues and Sherlock hasn't found any direct links between them. He has to find two of three possible direct links between clues to solve the crime — there are 3 ways to do it.

The third sample has four clues and the detective has already found one direct link between the first and the fourth clue. There are 8 ways to find two remaining clues to solve the crime.
import static java.lang.Math.*;
import java.io.*;
import java.math.*;
import java.util.*;

public class TaskD {
	MyScanner in;
	PrintWriter out;

	int n, m, k;
	DSU dsu;

	void load() throws Exception {
		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();

		dsu = new DSU(n);
		for (int i = 0; i < m; i++) {
			int u = in.nextInt() - 1;
			int v = in.nextInt() - 1;
			dsu.join(u, v);
		}
	}

	void solve() throws Exception {
		ArrayList<Integer> components = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			if (dsu.isRoot(i)) {
				components.add(dsu.size(i));
			}
		}

		long res = 1 % k;

		if (components.size() > 1) {
			for (int a : components) {
				res = (res * a) % k;
			}
			for (int i = 0; i < components.size() - 2; i++) {
				res = (res * n) % k;
			}
		}
		out.print(res);
	}

	class DSU {
		int par[];
		int rank[];
		int size[];

		public DSU(int n) {
			par = new int[n];
			rank = new int[n];
			size = new int[n];
			for (int i = 0; i < n; i++) {
				par[i] = i;
				size[i] = 1;
			}
		}

		public int size(int v) {
			return size[v];
		}

		public boolean isRoot(int v) {
			return v == par[v];
		}

		int root(int v) {
			if (isRoot(v)) {
				return v;
			} else {
				return par[v] = root(par[v]);
			}
		}

		boolean inComponent(int u, int v) {
			return root(u) == root(v);
		}

		void join(int u, int v) {
			if (inComponent(u, v)) {
				return;
			}
			int ru = root(u);
			int rv = root(v);
			if (rank[ru] > rank[rv]) {
				par[rv] = ru;
				size[ru] += size[rv];
			} else {
				par[ru] = rv;
				size[rv] += size[ru];
				if (rank[rv] == rank[ru]) {
					rank[rv]++;
				}
			}
		}
	}

	final String problem = "d";

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			boolean oj = System.getProperty("ONLINE_JUDGE") != null;
			in = oj ? new MyScanner() : new MyScanner(problem + ".in");
			out = oj ? new PrintWriter(System.out) : new PrintWriter(problem
					+ ".out");
			load();
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

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

	class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(String file) {
			try {
				br = new BufferedReader(new FileReader(new File(file)));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				System.exit(42);
			}
		}

		MyScanner() {
			try {
				br = new BufferedReader(new InputStreamReader(System.in));
			} catch (Exception e) {
				e.printStackTrace();
				System.exit(42);
			}
		}

		String nextToken() {
			while (st == null || (!st.hasMoreTokens())) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					System.exit(42);
				}
			}
			return st.nextToken();
		}

		int nextInt() throws Exception {
			return Integer.parseInt(nextToken());
		}

		double nextDouble() throws Exception {
			return Double.parseDouble(nextToken());
		}

		long nextLong() throws Exception {
			return Long.parseLong(nextToken());
		}

		BigInteger nextBigInteger(int radix) throws Exception {
			return new BigInteger(nextToken(), radix);
		}
	}

}