#include <bits/stdc++.h>
struct Candidate {
  std::vector<int> d;
  Candidate(std::vector<int> d_) {
    d = d_;
    std::sort(d.begin(), d.end());
    std::reverse(d.begin(), d.end());
  }
  inline bool operator<(const Candidate &rhs) {
    if (d[0] < 0 || rhs.d[0] < 0) return d[0] < rhs.d[0];
    for (int i = 0; i < static_cast<int>(d.size()); ++i)
      if (d[i] != rhs.d[i]) return d[i] < rhs.d[i];
    return false;
  }
};
int get_enemy_pos(std::vector<int> locations, bool mate) {
  std::cout << locations[0] + 1 << " " << locations[1] + 1 << " "
            << locations[2] + 1 << std::endl;
  if (!mate) {
    int pos;
    std::cin >> pos;
    return pos - 1;
  } else {
    return -1;
  }
}
std::vector<int> get_dist(std::vector<std::vector<int> > &adj, int src) {
  auto d = std::vector<int>(adj.size(), -1);
  auto q = std::queue<int>();
  q.push(src);
  d[src] = 0;
  while (!q.empty()) {
    int at = q.front();
    q.pop();
    for (auto &next : adj[at]) {
      if (d[next] < 0) {
        d[next] = d[at] + 1;
        q.push(next);
      }
    }
  }
  return d;
}
int main() {
  int nodes, edges;
  std::cin >> nodes >> edges;
  auto adj = std::vector<std::vector<int> >(nodes, std::vector<int>());
  for (int edge = 0; edge < edges; ++edge) {
    int src, dst;
    std::cin >> src >> dst;
    adj[src - 1].push_back(dst - 1);
    adj[dst - 1].push_back(src - 1);
  }
  srand(time(NULL));
  auto dists = std::vector<std::vector<int> >(static_cast<int>(adj.size()),
                                              std::vector<int>());
  int best_dist = nodes + 1;
  auto best_locs = std::vector<int>(3, -1);
  for (int iter = 0; iter < 5000; ++iter) {
    auto locs = std::vector<int>(3);
    for (int i = 0; i < static_cast<int>(locs.size()); ++i) {
      locs[i] = -1;
      bool ok = true;
      do {
        ok = true;
        locs[i] = rand() % nodes;
        for (int j = 0; j < i; ++j) {
          if (locs[i] == locs[j]) ok = false;
        }
      } while (!ok);
      if (dists[locs[i]].size() == 0) {
        dists[locs[i]] = get_dist(adj, locs[i]);
      }
    }
    int cand_dist = 1;
    for (int i = 0; i < nodes; ++i) {
      cand_dist = std::max(
          cand_dist, std::min(dists[locs[0]][i],
                              std::min(dists[locs[1]][i], dists[locs[2]][i])));
    }
    if (cand_dist < best_dist) {
      best_dist = cand_dist;
      best_locs = locs;
    }
  }
  auto locs = best_locs;
  auto enemy_pos = get_enemy_pos(locs, false);
  while (enemy_pos >= 0) {
    if (enemy_pos == locs[0] || enemy_pos == locs[1] || enemy_pos == locs[2]) {
      break;
    }
    auto targets = std::vector<int>();
    targets.push_back(enemy_pos);
    for (int repeats = 0; repeats < 0; ++repeats) {
      auto ntargets = std::vector<int>();
      for (auto &t : targets)
        for (auto &x : adj[t]) {
          ntargets.push_back(x);
        }
      for (auto &nt : ntargets) targets.push_back(nt);
      std::sort(targets.begin(), targets.end());
      targets.resize(std::unique(targets.begin(), targets.end()) -
                     targets.begin());
    }
    for (auto &x : targets) {
      if (dists[x].size() == 0) {
        dists[x] = get_dist(adj, x);
      }
    }
    auto d = std::vector<int>(static_cast<int>(locs.size()));
    auto best =
        Candidate(std::vector<int>(static_cast<int>(locs.size()), nodes + 1));
    static int best_locs[] = {-1, -1, -1};
    static int by[3];
    static int choice[3];
    for (int i = 0; i < 3; ++i) {
      std::random_shuffle(adj[locs[i]].begin(), adj[locs[i]].end());
    }
    for (choice[0] = 0; choice[0] <= adj[locs[0]].size(); ++choice[0])
      for (choice[1] = 0; choice[1] <= adj[locs[1]].size(); ++choice[1])
        for (choice[2] = 0; choice[2] <= adj[locs[2]].size(); ++choice[2]) {
          bool mate = false;
          for (int i = 0; i < 3; ++i) {
            by[i] = (choice[i] == 0 ? locs[i] : adj[locs[i]][choice[i] - 1]);
            if (by[i] == enemy_pos) mate = true;
          }
          if (by[0] == by[1] || by[1] == by[2] || by[0] == by[2]) {
            continue;
          }
          for (int j = 0; j < 3; ++j) d[j] = dists[targets[0]][by[j]];
          auto cand = Candidate(d);
          if (mate) {
            cand.d[0] = -1;
          }
          if (cand < best) {
            best = cand;
            for (int i = 0; i < 3; ++i) {
              best_locs[i] = by[i];
            }
          }
        }
    locs = std::vector<int>(best_locs, best_locs + 3);
    enemy_pos = get_enemy_pos(locs, best.d[0] < 0);
  }
  return 0;
}
