Requirements

* All inputs are of non-negative integer value.
* T_{\text{max}} = 10000
* 200 \leq |V| \leq 400
* 1.5 |V| \leq |E| \leq 2 |V|
* 1 \leq u_{i}, v_{i} \leq |V| (1 \leq i \leq |E|)
* 1 \leq d_{u_i, v_i} \leq \lceil 4\sqrt{2|V|} \rceil (1 \leq i \leq |E|)
* The given graph has no self-loops / multiple edges and is guaranteed to be connected.
* 0 \leq N_{\text{new}} \leq 1
* 1 \leq \mathrm{new\\_id}_{i} \leq T_{\text{last}}+1 (1 \leq i \leq N_{\text{new}}). Note: If all orders are generated by the order generation rule as explained above, the total number of orders is at most T_{\text{last}}+1. Therefore, the possible range of \mathrm{new\\_id}_{i} should be from 1 to T_{\text{last}}+1.
* 2 \leq \mathrm{dst}_i \leq |V| (1 \leq i \leq N_{\text{new}})
* The order IDs \mathrm{new\\_{id}}_i are unique.

Input Format

Input is provided in the following form:


|V| |E|
u_{1} v_{1} d_{u_{1}, v_{1}}
u_{2} v_{2} d_{u_{2}, v_{2}}
:
u_{|E|} v_{|E|} d_{u_{|E|}, v_{|E|}}
T_{\text{max}}
\mathrm{info}_{0}
\mathrm{info}_{1}
:
\mathrm{info}_{T_{\text{max}}-1}


* In the first line |V| denotes the number of vertices, while |E| denotes the number of edges.
* The following |E| lines denote the edges of the graph. In particular, in the ith line u_{i} and v_{i} denote the edge connecting u_{i} and v_{i} and d_{u_{i}, v_{i}} the corresponding distance.
* The following line denotes the number of steps T_{\text{max}}.



In the following line, \mathrm{info}_t is information about the order from the customer that occurs at time t. \mathrm{info}_t is given in the form:


N_{\text{new}}
\mathrm{new\_id}_1 \mathrm{dst}_1
\mathrm{new\_id}_2 \mathrm{dst}_2
\vdots
\mathrm{new\_id}_{N_{\text{new}}} \mathrm{dst}_{N_{\text{new}}}


* N_{\text{new}} represents the number of new orders which appear at time t.
* The next N_{\text{new}} lines give the newly generated order information. The i-th order information indicates that the order ID \mathrm{new\\_{id}}_i of the new order, while \mathrm{dst}_i denotes the vertex to which the customer wishes the order to be delivered.
* Note: If N_{\text{new}}=0, there are no new lines.

Output Format

The Output expects T_{\text{max}} integers in the format specified below.


\mathrm{command}_{0}
\mathrm{command}_{1}
:
\mathrm{command}_{T_{\text{max}}-1}


In particular, \mathrm{command}_{i} shall specify the movement of the delivery car by using one of the following two options:

1) `stay`, if the car shall not move:


-1


2) `move w`, if the car shall be moved one step towards the neighboring vertex w


w


Note that in case of 2) w has to satisfy the following conditions:

* w \in V
* If the car is at vertex u: \left\\{ u, w \right\\} \in E .
* If the car is on the edge \left\\{ u, v \right\\}, w must either satisfy u = w or v = w.



* * *

Examples

Input




Output




Input

5 7
1 2 5
5 3 4
2 4 8
1 5 1
2 3 3
4 5 3
4 3 9
4
1
1 2
1
2 5
1
3 4
0


Output

2
-1
1
5
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x^(x << 11));
	x = y; y = z; z = w;
	return (w = (w^(w >> 19))^(t^(t >> 8)));
}
vector<pair<int, int>> vertexs[500];
pair<int, int> go_move[500][500];

int is_problemb = 0;

void println(int now) {
	cout << now << endl;
	if (is_problemb == 1) {
		string s;
		cin >> s;
		int q;
		cin >> q;
		REP(i, q) {
			int a;
			cin >> a;
		}
	}
}
vector<int> inputln() {
	vector<int> tmp;
	int n;
	cin >> n;
	REP(q, n) {
		int a, b;
		cin >> a >> b;
		tmp.push_back(b);
	}
	if (is_problemb == 1) {
		int n;
		cin >> n;
		REP(q, n) {
			int a;
			cin >> a;
		}
	}
	return tmp;
}
int main() {
	int V, E;
	cin >> V >> E;
	REP(i, E) {
		int a, b, c;
		cin >> a >> b >> c;
		vertexs[a].push_back(make_pair(b, c));
		vertexs[b].push_back(make_pair(a, c));
	}
	REP(i, V) {
		REP(q, V) {
			go_move[i + 1][q + 1] = make_pair(10000000, 0);
		}
	}
	for (int i = 1; i <= V; ++i) {
		go_move[i][i] = make_pair(0, -1);
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> next;
		next.push(make_pair(0, i));
		while (next.empty() == false) {
			pair<int, int> now = next.top();
			next.pop();
			if (now.first != go_move[i][now.second].first) continue;
			REP(q, vertexs[now.second].size()) {
				int go = vertexs[now.second][q].first;
				int cost = vertexs[now.second][q].second + now.first;
				if (go_move[i][go].first > cost) {
					go_move[i][go] = make_pair(cost, now.second);
					next.push(make_pair(cost, go));
				}
			}
		}
	}
	if (is_problemb == 1) {
		REP(i, V) {
			int a;
			cin >> a;
		}
	}
	int T_max;
	cin >> T_max;
	vector<int> input_a, input_b;
	input_b.push_back(1);
	int now_time = 0;
	while (now_time < T_max) {
		vector<int> now = inputln();
		REP(q, now.size()) {
			input_b.push_back(now[q]);
		}
		int decide = input_b.size();
		if (decide <= 1) {
			now_time++;
			println(-1);
		}
		else {
			swap(input_a, input_b);
			set<int> now;
			for (int q = 0; q < input_a.size(); ++q) {
				if (now.find(input_a[q]) == now.end()) {
					now.insert(input_a[q]);
				}
				else {
					input_a.erase(input_a.begin() + q);
					q--;
				}
			}
			input_a.push_back(1);
			if (input_a.size() != 3) {
				for (int q = 0; q < 100000; ++q) {
					if (xor128() % 2 == 0) {
						int a = xor128() % (input_a.size() - 3) + 1;
						if (go_move[input_a[a - 1]][input_a[a]].first + go_move[input_a[a + 1]][input_a[a + 2]].first >
							go_move[input_a[a - 1]][input_a[a + 1]].first + go_move[input_a[a]][input_a[a + 2]].first) {
							swap(input_a[a], input_a[a + 1]);
						}
					}
					else {
						int a = xor128() % (input_a.size() - 2) + 1;
						int b = xor128() % (input_a.size() - 2) + 1;
						if (a > b) swap(a, b);
						if (a+1 >= b) {
							continue;
						}
						int cost = go_move[input_a[a - 1]][input_a[a]].first + go_move[input_a[a]][input_a[a + 1]].first;
						cost += go_move[input_a[b - 1]][input_a[b]].first + go_move[input_a[b]][input_a[b + 1]].first;
						swap(input_a[a], input_a[b]);
						cost -= go_move[input_a[a - 1]][input_a[a]].first + go_move[input_a[a]][input_a[a + 1]].first;
						cost -= go_move[input_a[b - 1]][input_a[b]].first + go_move[input_a[b]][input_a[b + 1]].first;
						if (cost < 0) {
							swap(input_a[a], input_a[b]);
						}
					}
				}
			}
			input_b.push_back(1);
			vector<int> going;
			for (int q = 1; q < input_a.size(); ++q) {
				vector<int> tea;
				int now = input_a[q];
				while (now != input_a[q - 1]) {
					int next_go = go_move[input_a[q - 1]][now].second;
					int hoge = go_move[input_a[q - 1]][now].first - go_move[input_a[q - 1]][next_go].first;
					REP(q, hoge) {
						tea.push_back(now);
					}
					now = next_go;
				}
				REP(q, tea.size()) {
					going.push_back(tea[tea.size() - q - 1]);
				}
			}
			println(going[0]);
			while (now_time + going.size() > T_max) {
				going.pop_back();
			}
			for (int q = 1; q < going.size(); ++q) {
				vector<int> now = inputln();
				REP(q, now.size()) {
					input_b.push_back(now[q]);
				}
				println(going[q]);
			}
			now_time += going.size();
			input_a.clear();
		}
	}
	return 0;
}
