Problem: You must have heard all about the Foolland on your Geography lessons. Specifically, you must know that federal structure of this country has been the same for many centuries. The country consists of n cities, some pairs of cities are connected by bidirectional roads, each road is described by its length li.

The fools lived in their land joyfully, but a recent revolution changed the king. Now the king is Vasily the Bear. Vasily divided the country cities into regions, so that any two cities of the same region have a path along the roads between them and any two cities of different regions don't have such path. Then Vasily decided to upgrade the road network and construct exactly p new roads in the country. Constructing a road goes like this:

  1. We choose a pair of distinct cities u, v that will be connected by a new road (at that, it is possible that there already is a road between these cities). 
  2. We define the length of the new road: if cities u, v belong to distinct regions, then the length is calculated as min(109, S + 1) (S — the total length of all roads that exist in the linked regions), otherwise we assume that the length equals 1000. 
  3. We build a road of the specified length between the chosen cities. If the new road connects two distinct regions, after construction of the road these regions are combined into one new region. 



Vasily wants the road constructing process to result in the country that consists exactly of q regions. Your task is to come up with such road constructing plan for Vasily that it meets the requirement and minimizes the total length of the built roads.

Input

The first line contains four integers n (1 ≤ n ≤ 105), m (0 ≤ m ≤ 105), p (0 ≤ p ≤ 105), q (1 ≤ q ≤ n) — the number of cities in the Foolland, the number of existing roads, the number of roads that are planned to construct and the required number of regions.

Next m lines describe the roads that exist by the moment upgrading of the roads begun. Each of these lines contains three integers xi, yi, li: xi, yi — the numbers of the cities connected by this road (1 ≤ xi, yi ≤ n, xi ≠ yi), li — length of the road (1 ≤ li ≤ 109). Note that one pair of cities can be connected with multiple roads.

Output

If constructing the roads in the required way is impossible, print a single string "NO" (without the quotes). Otherwise, in the first line print word "YES" (without the quotes), and in the next p lines print the road construction plan. Each line of the plan must consist of two distinct integers, giving the numbers of the cities connected by a road. The road must occur in the plan in the order they need to be constructed. If there are multiple optimal solutions, you can print any of them.

Examples

Input

9 6 2 2
1 2 2
3 2 1
4 6 20
1 3 8
7 8 3
5 7 2


Output

YES
9 5
1 9


Input

2 0 1 2


Output

NO


Input

2 0 0 2


Output

YES

Note

Consider the first sample. Before the reform the Foolland consists of four regions. The first region includes cities 1, 2, 3, the second region has cities 4 and 6, the third region has cities 5, 7, 8, the fourth region has city 9. The total length of the roads in these cities is 11, 20, 5 and 0, correspondingly. According to the plan, we first build the road of length 6 between cities 5 and 9, then the road of length 23 between cities 1 and 9. Thus, the total length of the built roads equals 29.

Solution (in JAVA):

Solution:
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.io.OutputStreamWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Stanislav Pak
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n = in.readInt();
		int m = in.readInt();
		int p = in.readInt();
		int q = in.readInt();
		IndependentSetSystem iss = new RecursiveIndependentSetSystem(n);
		Map<Integer, Long> idToWeight = new HashMap<>();
		for (int i = 0; i < n; ++i) idToWeight.put(i, 0L);
		int uu = -1;
		int vv = -1;
		for (int i = 0; i < m; ++i) {
			int u = in.readInt() - 1;
			int v = in.readInt() - 1;
			long w = in.readInt();
			uu = u;
			vv = v;
			u = iss.get(u);
			v = iss.get(v);
			if (u == v) {
				idToWeight.put(u, idToWeight.get(u) + w);
			} else {
				w += idToWeight.get(u) + idToWeight.get(v);
				iss.join(u, v);
				u = iss.get(u);
				idToWeight.put(u, w);
			}
		}
		if (q > iss.getSetCount()) {
			out.printLine("NO");
			return;
		}
		if (q == n && p > 0) {
			out.printLine("NO");
			return;
		}
		q = iss.getSetCount() - q;
		TreeSet<Pair<Long, Integer>> queue = new TreeSet<>();
		for (int v = 0; v < n; ++v) {
			int parent = iss.get(v);
			if (!idToWeight.containsKey(parent)) continue;
			long w = idToWeight.get(parent);
			idToWeight.remove(parent);
			queue.add(Pair.makePair(w, parent));
		}
		if (q > p) {
			out.printLine("NO");
			return;
		}
		out.printLine("YES");
		while (q > 0) {
			Pair<Long, Integer> first = queue.pollFirst();
			Pair<Long, Integer> second = queue.pollFirst();
			uu = first.second;
			vv = second.second;
			out.printLine(first.second + 1, second.second + 1);
			long w = Math.min(first.first + second.first + 1, 1000000000L);
			w += first.first + second.first;
			queue.add(Pair.makePair(w, first.second));
			--q;
			--p;
		}
		while (p > 0) {
			out.printLine(uu + 1, vv + 1);
			--p;
		}
    }
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}

}

interface IndependentSetSystem {
	public boolean join(int first, int second);

	public int get(int index);

	public int getSetCount();

	public static interface Listener {
		public void joined(int joinedRoot, int root);
	}
}

class RecursiveIndependentSetSystem implements IndependentSetSystem {
	private final int[] color;
	private final int[] rank;
	private int setCount;
	private Listener listener;

	public RecursiveIndependentSetSystem(int size) {
		color = new int[size];
		rank = new int[size];
		for (int i = 0; i < size; i++)
			color[i] = i;
		setCount = size;
	}

	public boolean join(int first, int second) {
		first = get(first);
		second = get(second);
		if (first == second)
			return false;
		if (rank[first] < rank[second]) {
			int temp = first;
			first = second;
			second = temp;
		} else if (rank[first] == rank[second])
			rank[first]++;
		setCount--;
		color[second] = first;
		if (listener != null)
			listener.joined(second, first);
		return true;
	}

	public int get(int index) {
		if (color[index] == index)
			return index;
		return color[index] = get(color[index]);
	}

	public int getSetCount() {
		return setCount;
	}

}

class Pair<U, V> implements Comparable<Pair<U, V>> {
	public final U first;
	public final V second;

	public static<U, V> Pair<U, V> makePair(U first, V second) {
		return new Pair<U, V>(first, second);
	}

	private Pair(U first, V second) {
		this.first = first;
		this.second = second;
	}

	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		Pair pair = (Pair) o;

		return !(first != null ? !first.equals(pair.first) : pair.first != null) && !(second != null ? !second.equals(pair.second) : pair.second != null);

	}

	public int hashCode() {
		int result = first != null ? first.hashCode() : 0;
		result = 31 * result + (second != null ? second.hashCode() : 0);
		return result;
	}

	public String toString() {
		return "(" + first + "," + second + ")";
	}

	public int compareTo(Pair<U, V> o) {
		int value = ((Comparable<U>)first).compareTo(o.first);
		if (value != 0)
			return value;
		return ((Comparable<V>)second).compareTo(o.second);
	}
}