#include <bits/stdc++.h>
using namespace std;
const long long N = 5010, INF = 1e9;
long long n;
vector<long long> g[N];
long long dist[3][N];
void bfs(long long from, long long* dist, long long nastya) {
  for (long long i = 1; i <= n; i++) dist[i] = INF;
  dist[from] = 0;
  queue<long long> q;
  q.push(from);
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    for (long long to : g[v])
      if (dist[to] == INF && to != nastya) dist[to] = dist[v] + 1, q.push(to);
  }
}
array<long long, 5> calc(long long a, long long b, long long c, long long v,
                         long long first, long long second, long long z) {
  long long neighbours = -1, mxdist = -1, a1 = -1, b1 = -1, c1 = -1;
  neighbours = (set<long long>{first, second, z}).size();
  mxdist = -max({dist[first][a], dist[second][b], dist[z][c]});
  if (mxdist == -INF)
    return neighbours = -INF,
           array<long long, 5>{neighbours, mxdist, a1, b1, c1};
  for (long long to : g[a])
    if (dist[first][to] < dist[first][a]) a1 = to;
  for (long long to : g[b])
    if (dist[second][to] < dist[second][b]) b1 = to;
  for (long long to : g[c])
    if (dist[z][to] < dist[z][c]) c1 = to;
  return array<long long, 5>{neighbours, mxdist, a1, b1, c1};
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0) ^ ((long long)(new char)));
  long long m;
  cin >> n >> m;
  while (m--) {
    long long v, u;
    cin >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  long long a = rand() % n + 1, b = rand() % n + 1, c = rand() % n + 1;
  cout << a << " " << b << " " << c << endl;
  long long v;
  cin >> v;
  for (long long _ = 0; _ < n; _++) {
    if (a == v || b == v || c == v) exit(0);
    if (count(g[a].begin(), g[a].end(), v))
      cout << v << " " << b << " " << c << endl, exit(0);
    if (count(g[b].begin(), g[b].end(), v))
      cout << a << " " << v << " " << c << endl, exit(0);
    if (count(g[c].begin(), g[c].end(), v))
      cout << a << " " << b << " " << v << endl, exit(0);
    for (long long t = 0; t < g[v].size(); t++) bfs(g[v][t], dist[t], v);
    array<long long, 5> res{-INF, -INF, -INF, -INF, -INF};
    for (long long first = 0; first < g[v].size(); first++)
      for (long long second = 0; second < g[v].size(); second++)
        for (long long z = 0; z < g[v].size(); z++)
          res = max(res, calc(a, b, c, v, first, second, z));
    a = res[2], b = res[3], c = res[4];
    cout << a << " " << b << " " << c << endl;
    if (a == v || b == v || c == v) exit(0);
    cin >> v;
  }
}
