#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> nxt[5301];
int md[5301];
int dist[5301][5301];
int head, tail;
int q[5301];
void seek(int u) {
  head = tail = 0;
  head++;
  q[head] = u;
  dist[u][u] = 0;
  while (head > tail) {
    tail++;
    int t = q[tail];
    for (int j = 0; j < nxt[t].size(); j++) {
      int nt = nxt[t][j];
      if (dist[u][nt] == -1) {
        dist[u][nt] = dist[u][t] + 1;
        head++;
        q[head] = nt;
      }
    }
  }
}
int pos[4];
int cPos = -1;
int printPos(int a, int b, int c) {
  pos[1] = a;
  pos[2] = b;
  pos[3] = c;
  printf("%d %d %d\n", a, b, c);
  fflush(stdout);
  if (cPos != a && cPos != b && cPos != c) {
    scanf("%d", &cPos);
    if (cPos == a || cPos == b || cPos == c) {
      return -1;
    } else {
      return cPos;
    }
  } else {
    return -1;
  }
}
int vv[5301][4] = {
    {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1},
};
int tPos[4], vPos[4];
int ng[4];
int tt(int per) {
  for (int i = 1; i <= 3; i++) {
    int my = vv[per][i - 1];
    int pp = pos[i];
    tPos[i] = pp;
    for (int j = 0; j < nxt[pp].size(); j++) {
      int cad = nxt[pp][j];
      if (dist[cad][ng[my]] < dist[tPos[i]][ng[my]]) tPos[i] = cad;
    }
  }
  int ret = 0;
  for (int i = 1; i <= 3; i++) {
    int my = vv[per][i - 1];
    ret += dist[tPos[i]][ng[my]];
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    nxt[u].push_back(v);
    nxt[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) dist[i][j] = -1;
    seek(i);
    md[i] = dist[i][1];
    for (int j = 1; j <= n; j++) md[i] = max(md[i], dist[i][j]);
  }
  int good = 1;
  for (int i = 1; i <= n; i++) {
    if (md[i] < md[good]) good = i;
  }
  int v = printPos(good, good, good);
  if (v == -1) return 0;
  int cnt = 0;
  while (true) {
    cnt++;
    if (cnt > n) {
      int a = 1;
      int b = 0;
      int c = a / b;
      int d = c + b;
    }
    ng[1] = nxt[cPos][0];
    ng[2] = (nxt[cPos].size() > 1 ? nxt[cPos][1] : ng[1]);
    ng[3] = (nxt[cPos].size() > 2 ? nxt[cPos][2] : ng[2]);
    int md;
    for (int k = 0; k <= 5; k++) {
      int res = tt(k);
      if (k == 0 || res < md) {
        md = res;
        for (int j = 1; j <= 3; j++) vPos[j] = tPos[j];
      }
    }
    int v = printPos(vPos[1], vPos[2], vPos[3]);
    if (v == -1) return 0;
  }
}
