public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num_centers = Integer.parseInt(br.readLine().trim());
		
		//create a correspondence between data and the centers that own them
		HashMap<Integer, ArrayList<Integer>> data_to_center = new HashMap<Integer, ArrayList<Integer>>();

		int index = 1;
		while (index <= num_centers) {
			String data = br.readLine();
			
			//thus get around the problem of null line
			if (data != null && !data.equals("")) {
				String[] datum = data.split(" ");
				for (int i = 0; i < datum.length; i++) {
					int piece = Integer.parseInt(datum[i]);
					if (data_to_center.containsKey(piece)) {
						data_to_center.get(piece).add(index);
					} else {
						ArrayList<Integer> centers = new ArrayList<Integer>();
						centers.add(index);
						data_to_center.put(piece, centers);
					}
				}
			}
			index++;
		}

		//for each piece of data, find out which center misses it and use the
		//first center that owns it as the default source to send the data
		for (Map.Entry<Integer, ArrayList<Integer>> entry : data_to_center.entrySet()) {
			int data = entry.getKey();
			ArrayList<Integer> centers = entry.getValue();
			int src_center = centers.get(0);
			for (int i = 1; i <= num_centers; i++) {
				if (centers.contains(i) == false) {
					int dest_center = i;
					System.out.println(data + " " + src_center + " " + dest_center);
				}
			}
		}
		System.out.println("done");
	}