#include <bits/stdc++.h>
using namespace std;
vector<int> adjList[5000];
int dist[5000][5000];
queue<int> Q;
int sq(int n) { return n * n; }
pair<int, int> d(int a, int b, int c) {
  return make_pair(dist[a][b] + dist[b][c] + dist[c][a],
                   -(sq(dist[a][b]) + sq(dist[b][c]) + sq(dist[c][a])));
}
int main() {
  int i;
  int n, m, u, v;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    u--, v--;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
  }
  int j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) dist[i][j] = -1;
    dist[i][i] = 0, Q.push(i);
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      for (j = 0; j < adjList[u].size(); j++) {
        int v = adjList[u][j];
        if (dist[i][v] == -1) {
          dist[i][v] = dist[i][u] + 1;
          Q.push(v);
        }
      }
    }
  }
  int a = 0, b = 1, c = 2;
  for (i = 0; i < 1e6 / n; i++) {
    int aa = rand() % n, bb = rand() % n, cc = rand() % n;
    while (1) {
      int f = 0;
      for (j = 0; j < adjList[aa].size(); j++) {
        int v = adjList[aa][j];
        if (d(aa, bb, cc) < d(v, bb, cc)) {
          aa = v, f = 1;
          break;
        }
      }
      for (j = 0; j < adjList[bb].size(); j++) {
        int v = adjList[bb][j];
        if (d(aa, bb, cc) < d(aa, v, cc)) {
          bb = v, f = 1;
          break;
        }
      }
      for (j = 0; j < adjList[cc].size(); j++) {
        int v = adjList[cc][j];
        if (d(aa, bb, cc) < d(aa, bb, v)) {
          cc = v, f = 1;
          break;
        }
      }
      if (!f) break;
    }
    if (d(a, b, c) < d(aa, bb, cc)) a = aa, b = bb, c = cc;
  }
  int k, l;
  cout << a + 1 << " " << b + 1 << " " << c + 1 << endl;
  cin >> u, u--;
  for (i = 0; i < n; i++) adjList[i].push_back(i);
  while (1) {
    int na = a, nb = b, nc = c, z = 1e9;
    for (i = 0; i < adjList[a].size(); i++) {
      for (j = 0; j < adjList[b].size(); j++) {
        for (k = 0; k < adjList[c].size(); k++) {
          int aa = adjList[a][i], bb = adjList[b][j], cc = adjList[c][k];
          int m = 0;
          for (l = 0; l < adjList[u].size(); l++) {
            int v = adjList[u][l];
            m = max(m, dist[v][aa] + dist[v][bb] + dist[v][cc]);
          }
          if (m < z) na = aa, nb = bb, nc = cc, z = m;
        }
      }
    }
    a = na, b = nb, c = nc;
    cout << a + 1 << " " << b + 1 << " " << c + 1 << endl;
    if ((a == u) || (b == u) || (c == u))
      break;
    else {
      cin >> u, u--;
      if ((a == u) || (b == u) || (c == u)) break;
    }
  }
  return 0;
}
