description: On the great island of Baltia, there live N people, numbered from 1 to N. There are exactly M pairs of people that are friends with each other. The people of Baltia want to organize a successful party, but they have very strict rules on what a party is and when the party is successful. On the island of Baltia, a party is a gathering of exactly 5 people. The party is considered to be successful if either all the people at the party are friends with each other (so that they can all talk to each other without having to worry about talking to someone they are not friends with) or no two people at the party are friends with each other (so that everyone can just be on their phones without anyone else bothering them). Please help the people of Baltia organize a successful party or tell them that it's impossible to do so.
  
  Input
  
  The first line contains two integer numbers, N (5 ≤ N ≤ 2*10^5) and M (0 ≤ M ≤ 2*10^5) – the number of people that live in Baltia, and the number of friendships. The next M lines each contains two integers U_i and V_i (1 ≤ U_i,V_i ≤ N) – meaning that person U_i is friends with person V_i. Two friends can not be in the list of friends twice (no pairs are repeated) and a person can be friends with themselves (U_i ≠ V_i).
  
  Output
  
  If it's possible to organize a successful party, print 5 numbers indicating which 5 people should be invited to the party. If it's not possible to organize a successful party, print -1 instead. If there are multiple successful parties possible, print any.
  
  Examples
  
  Input
  
  
  6 3
  1 4
  4 2
  5 4
  
  
  Output
  
  
  1 2 3 5 6
  
  
  Input
  
  
  5 4
  1 2
  2 3
  3 4
  4 5
  
  
  Output
  
  
  -1
solution: #include <bits/stdc++.h>
  using namespace std;
  int n, m;
  inline int read() {
    int x;
    scanf("%d", &x);
    return x;
  }
  const int N = 100005;
  struct node {
    int to, nxt;
  } e[N << 1];
  int head[N], tot;
  inline void add(int u, int v) {
    e[++tot].to = v, e[tot].nxt = head[u], head[u] = tot;
    e[++tot].to = u, e[tot].nxt = head[v], head[v] = tot;
  }
  int a[6];
  inline bool check() {
    bool f1 = 1, f2 = 1;
    int cnt[5];
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= 5; ++i) {
      for (int j = head[a[i]]; j; j = e[j].nxt) {
        int v = e[j].to;
        for (int k = 1; k <= 5; ++k) {
          if (v == a[k]) f1 = 0, ++cnt[i];
        }
      }
    }
    for (int i = 1; i <= 5; ++i) {
      if (cnt[i] < 4) f2 = 0;
    }
    return f1 || f2;
  }
  map<long long, int> ma;
  int main() {
    srand(time(0));
    n = read(), m = read();
    for (int i = 1, u, v; i <= m; ++i) {
      u = read(), v = read();
      add(u, v);
    }
    int maxx = min(n, 60);
    int b[100];
    for (int i = 1; i <= maxx; ++i) b[i] = 0;
    for (int i = 1; i <= 5; ++i) b[maxx - i + 1] = 1;
    do {
      int kkk = 0;
      for (int i = 1; i <= maxx; ++i) {
        if (b[i] == 1) a[++kkk] = i;
      }
      if (check()) {
        for (int i = 1; i <= 5; ++i) {
          printf("%d ", a[i]);
        }
        cout << endl;
        return 0;
      }
    } while (next_permutation(b + 1, b + 1 + maxx));
    puts("-1");
    return 0;
  }
  