#include <bits/stdc++.h>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<vector<vector<ll>>> vvvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


struct order {
  int id, dst;

  order(int id, int dst) : id(id), dst(dst) {}
};

const int64_t CYCLES_PER_SEC = 2800000000;

struct Timer {
  int64_t start;
  Timer() { reset(); }
  void reset() { start = getCycle(); }
  void plus(double a) { start -= (a * CYCLES_PER_SEC); }
  inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
  inline int64_t getCycle() {
    uint32_t low, high;
    __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
    return ((int64_t)low) | ((int64_t)high << 32);
  }
};

class XorShift {
public:
  unsigned int x, y, z, w;
  double nL[65536];

  XorShift()
  {
    init();
  }

  void init()
  {
    x = 314159265; y = 358979323; z = 846264338; w = 327950288;
    double n = 1 / (double)(2 * 65536);
    for (int i = 0; i < 65536; i++) {
      nL[i] = log(((double)i / 65536) + n);
    }
  }
  void setSeed(int seed) {
    x = 314159265; y = 358979323; z = 846264338; w = 327950288 + seed;
    for (int i = 0; i < 500; i++) {
      next();
    }
  }
  inline unsigned int next()
  {
    unsigned int t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
  }

  inline double nextLog() {
    return nL[next() & 0xFFFF];
  }

  inline int nextInt(int m)
  {
    return (int)(next() % m);
  }


  int nextInt(int min, int max)
  {
    return min + nextInt(max - min + 1);
  }


  double nextDouble()
  {
    return (double)next() / ((long long)1 << 32);
  }


};



// グローバル変数
Timer timer;
XorShift rnd;

ll V, E;
WeightedGraph<ll> wg;
ll Tmax;

vector<order> info;


void input(){
  cin>>V>>E;

  wg.resize(V);
  rep(i, E){
    ll u, v, d;
    cin>>u>>v>>d;
    u--;
    v--;
    wg[u].emplace_back(v, d);
    wg[v].emplace_back(u, d);
  }

  cin>>Tmax; // 10000
  // info.resize(Tmax);

  rep(i, Tmax){
    int Nnew; cin>>Nnew;

    rep(i, Nnew){
      int new_id, dst;
      cin>>new_id>>dst;
      new_id--;
      info.emplace_back(new_id, dst);
    }
  }

};

void output(){

  rep(i, Tmax){
    cout<<-1<<endl;
  }

};








int main() {
  cout<<fixed<<setprecision(12);

  input();

  // solveGreedy();
  // solveClimb();
  output();

  // cout<<bestScr<<endl;


  



}


Measured memory_bytes: 896