In the galaxy far far away is the ancient interplanetary republic of Bubbleland, consisting of N planets. Between them, there are M bidirectional wormholes, each connecting a pair of planets. Bubbleland is a very centralized republic, having a capital planet Whiteplanet, from which any another planet can be reached using these wormholes. It is also guaranteed that no wormhole connects planet to itself and that no two different wormholes connect same pair of planets. 

We call a path that begins at one planet, visits other planets and each of them at most once and returns to starting point a tour. Interplanetary Safety Regulations guarantee that each planet belongs to at most one tour and that there are at most 42 tours.

After many eons of usage, wormholes need to be repaired and each wormhole has the cost W_{i} which needs to be payed for reparation. Unfortunately, the Senate of Bubbleland is short on budget. Therefore, they have decided only to fix as many wormholes as they need in order to have all planets reachable from capital and to pay as little money as they have to for this repair. However the way in which the Senate calculates the cost is different. Cost of the set of reparations is binary xor of costs of each individual reparation, that is if reparations to be made have costs A_{1},A_{2},...,A_{k}, the cost of entire set is A_{1} ⊕ A_{2} ⊕ ... ⊕ A_{k}.

Now the Senate would like to know how much money do they have to pay and also the number of different ways to achieve that cost modulo 1000000007.

Input

First line of input contains two numbers N (1 ≤ N ≤ 100.000), the number of planets and M (1 ≤ M ≤ 100.041), the number of wormholes. Following M lines contain three numbers U, V (1 ≤ U ≠ V ≤ N) and W (1 ≤ W ≤ 100.000), meaning that there exists a wormhole connecting planets U and V, with repair cost of W.

Output

Output two numbers, the smallest possible cost of entire reparation and the number of different valid reparations with that cost modulo 1000000007.

Example

Input


6 6
4 1 5
5 2 1
6 3 2
1 2 6
1 3 3
2 3 4


Output


1 1

Note

We can repair wormholes 1,2,3,5 and 6, paying 5 ⊕ 1⊕ 2 ⊕ 3 ⊕ 4=1, one can check that this is the cheapest repair in which all of the planets are connected and the only valid repair with that cost.
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class D implements Runnable {
	public static void main (String[] args) {new Thread(null, new D(), "_cf", 1 << 28).start();}

	int[] onCycle;
	int[][] adj;
	int[][] adjW;
	int sPtr, par[], weights[];
	ArrayList<IntList> cycles;
	
	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int totalCost = 0;
		cycles = new ArrayList<>();
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		int[] deg = new int[n];
		int[][] es = new int[m][3];
		for(int i = 0; i < m; i++) {
			es[i][0] = fs.nextInt()-1;
			es[i][1] = fs.nextInt()-1;
			deg[es[i][0]]++; deg[es[i][1]]++;
			es[i][2] = fs.nextInt();
		}
		adj = new int[n][];
		adjW = new int[n][];
		for(int i = 0; i < n; i++) {
			adj[i] = new int[deg[i]];
			adjW[i] = new int[deg[i]];
			deg[i] = 0;
		}
		for(int i = 0; i < m; i++) {
			int u = es[i][0];
			int v = es[i][1];
			int we = es[i][2];
			totalCost ^= we;
			adj[u][deg[u]] = v; adjW[u][deg[u]] = we; deg[u]++;
			adj[v][deg[v]] = u; adjW[v][deg[v]] = we; deg[v]++;
		}
		
		par = new int[n];
		weights = new int[n];
		onCycle = new int[n];
		for(int i = 0; i < n; i++) {
			if(onCycle[i] == 0) {
				sPtr = 0;
				dfs(i, -1);
			}
		}
		
		int[] curWays = null;
		int[] numWays = null;
		for(int i = 0; i < cycles.size(); i++) {
			int[] nxt = new int[SIZE];
			int[] nxt2 = new int[SIZE];
			IntList curCycle = cycles.get(i);
			for(int ii = 0; ii < curCycle.size(); ii++) {
				int x = curCycle.get(ii);
				nxt2[x] = 1;
				nxt[x]++;
			}
			if(curWays == null) {
				curWays = nxt;
				numWays=  nxt2;
			}
			else {
				curWays = multXOR(curWays, nxt, true);
				numWays = multXOR(numWays, nxt2, false);
			}
			
		}
		
		int min = Integer.MAX_VALUE;
		int ways = 1;
		for(int i = 0; i < curWays.length; i++) {
			if(numWays[i] == 0) continue;
			int gets = totalCost ^ i;
			if(gets <= min) {
				if(gets < min) {
					min = gets;
					ways = curWays[i];
				}
				else {
					ways = add(ways, curWays[i]);
				}
			}
		}
		out.println(min + " " + ways);

		out.close();
	}
	
	int[] multXOR(int[] a1, int[] a2, boolean doMod) {
		a1 = fftXor(a1, a1.length, false, doMod);
		a2 = fftXor(a2, a2.length, false, doMod);
		for(int i = 0; i < a1.length; i++) {
			if(doMod)
				a1[i] = mult(a1[i], a2[i]);
			else
				a1[i] = a1[i] * a2[i];
		}
		a1 = fftXor(a1, a1.length, true, doMod);
//		for(int i = 0; i < a1.length; i++) a1[i] %= MOD;
		return a1;
	}

	void dfs(int u, int p) {
		onCycle[u] = 1;
		for(int ii = 0; ii < adj[u].length; ii++) {
			int v = adj[u][ii];
			int we = adjW[u][ii];
			if(v == p) continue;
			if(onCycle[v] == 1) {
				IntList addCycle = new IntList();
				int cur = u;
				while(cur != v) {
					addCycle.add(weights[cur]);
					cur = par[cur];
				}
				addCycle.add(we);
				cycles.add(addCycle);
			}
			else if(onCycle[v] == 0) {
				weights[v] = we;
				par[v] = u;
				dfs(v, u);
			}
		}
		
		onCycle[u] = 2;
	}

	int MOD = 1000000007;
	int SIZE = 1 << 17;
	int inv = BigInteger.valueOf(1 << 17).modInverse(BigInteger.valueOf(MOD)).intValue();
	
	int[] fftXor(int[] arr, int n, boolean invert, boolean doMod) {
		int[] ans = Arrays.copyOf(arr, n);
        for (int b = 1; b < n; b <<= 1)
            for (int i = 0; i < n; i++) {
                if((i & b) != 0) continue;
                int u = ans[i], v = ans[i+b];
                if(doMod) {
                	ans[i] = add(u , v);  ans[i + b] = sub(u , v);
                }
                else {
                	ans[i] = u+v; ans[i+b] = u-v;
                }
            }
        if (invert) for (int i = 0; i < n; i++) {
        	if(doMod) ans[i] = mult(ans[i], inv);
        	else ans[i] /= n;
        }
        return ans;
    }
	
	int add(int a, int b) {
		a += b;
		if(a >= MOD) a -= MOD;
		return a;
	}
	
	int mult(long a, long b) {
		a *= b;
		if(a >= MOD) a %= MOD;
		return (int)a;
	}
	
	int sub(int a, int b) {
		a -= b;
		if(a < 0) a += MOD;
		return a;
	}
	
	class IntList {
		int[] EMPTY = {};
		int n = 0, a[] = EMPTY;
		void add(int v) {
			if (n >= a.length)
				a = Arrays.copyOf(a, (n << 2) + 8);
			a[n++] = v;
		}
		int get(int idx) { return a[idx]; }
		int size() { return n; }
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}