#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 1e6 + 10;
int n, m, t;
vector<int> es[N];
vector<int> vec[N];
int d[N], fa[N];
void dfs(int x) {
  vec[d[x] % (t - 1)].push_back(x);
  for (auto &y : es[x]) {
    if (d[y] == -1) {
      fa[y] = x;
      d[y] = d[x] + 1;
      dfs(y);
    } else if (d[x] - d[y] + 1 >= t) {
      puts("2");
      printf("%d\n", d[x] - d[y] + 1);
      while (x != fa[y]) {
        printf("%d ", x);
        x = fa[x];
      }
      exit(0);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    es[x].push_back(y);
    es[y].push_back(x);
  }
  t = ceil(sqrt(n));
  memset(d, -1, sizeof(d));
  d[1] = 0;
  dfs(1);
  for (int i = 0; i < t - 1; i++) {
    if (vec[i].size() >= t) {
      puts("1");
      for (int j = 0; j < t; j++) printf("%d ", vec[i][j]);
      break;
    }
  }
}
