/* So, lets start coding

                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

 Author: Anuj Jhawar
   University: DAI-ICT, Gandhinagar, India.
   ID: fucking_noob */

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")

#include<bits/stdc++.h>
using namespace std;

const long long int  MOD = 1e9 + 7;
const long long int INF = 1e18;
#define pb push_back
#define ff first
#define ss second
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define ll long long int
#define srt(a) sort(a.begin(),a.end())
#define srtc(a,c) sort(a.begin(),a.end(),c);
#define fi(i,a,b) for(long long int i = a;i>=b;i--)
#define vectori vector<long long int>
#define vectorc vector<char>
#define ma(v) max_element(v.begin(),v.end())
#define mi(v) min_element(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define up(v,x) upper_bound(v.begin(),v.end(),x)
#define lo(v,x) lower_bound(v.begin(),v.end(),x)
#define endl "\n"

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll g = __gcd(a,b);
	ll t;
	cin>>t;
	while(t--)
	{
	   ll low,high;
	   cin>>low>>high;
	   if(g>=low&&g<=high)
	   {
	       cout<<g<<endl;
	       continue;
	   }
	   ll ans = -1;
	   for(ll i = min(high,g);i>=low&&i>=(ll)sqrt(g);i--)
	   {
	       if(g%i==0)
	       {
	           ans = i;
	           break;
	       }
	   }
	   if(ans==-1)
	   {
	       for(ll i = max(low,(ll)1);i<=high&&i*i<=g;i++)
	       {
	           if(g%i==0)
	           {
	               ans = i;
	           }
	       }
	   }
	   cout<<ans<<endl;
	}
 	return 0;
}


/* So, lets start coding

                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

 Author: Anuj Jhawar
   University: DAI-ICT, Gandhinagar, India.
   ID: fucking_noob */

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")

#include<bits/stdc++.h>
using namespace std;

const long long int  MOD = 1e9 + 7;
const long long int INF = 1e18;
#define pb push_back
#define ff first
#define ss second
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define ll long long int
#define srt(a) sort(a.begin(),a.end())
#define srtc(a,c) sort(a.begin(),a.end(),c);
#define fi(i,a,b) for(long long int i = a;i>=b;i--)
#define vectori vector<long long int>
#define vectorc vector<char>
#define ma(v) max_element(v.begin(),v.end())
#define mi(v) min_element(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define up(v,x) upper_bound(v.begin(),v.end(),x)
#define lo(v,x) lower_bound(v.begin(),v.end(),x)
#define endl "\n"

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll g = __gcd(a,b);
	ll t;
	cin>>t;
	while(t--)
	{
	   ll low,high;
	   cin>>low>>high;
	   if(g>=low&&g<=high)
	   {
	       cout<<g<<endl;
	       continue;
	   }
	   ll ans = -1;
	   for(ll i = min(high,g);i>=low&&i>=(ll)sqrt(g);i--)
	   {
	       if(g%i==0)
	       {
	           ans = i;
	           break;
	       }
	   }
	   if(ans==-1)
	   {
	       for(ll i = max(low,(ll)2);i<=high&&i*i<=g;i++)
	       {
	           if(g%i==0)
	           {
	               ans = i;
	           }
	       }
	   }
	   cout<<ans<<endl;
	}
 	return 0;
}


/* So, lets start coding

                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

 Author: Anuj Jhawar
   University: DAI-ICT, Gandhinagar, India.
   ID: fucking_noob */

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")

#include<bits/stdc++.h>
using namespace std;

const long long int  MOD = 1e9 + 7;
const long long int INF = 1e18;
#define pb push_back
#define ff first
#define ss second
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define ll long long int
#define srt(a) sort(a.begin(),a.end())
#define srtc(a,c) sort(a.begin(),a.end(),c);
#define fi(i,a,b) for(long long int i = a;i>=b;i--)
#define vectori vector<long long int>
#define vectorc vector<char>
#define ma(v) max_element(v.begin(),v.end())
#define mi(v) min_element(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define up(v,x) upper_bound(v.begin(),v.end(),x)
#define lo(v,x) lower_bound(v.begin(),v.end(),x)
#define endl "\n"

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll t;
	cin>>t;
	while(t--)
	{
	   ll low,high;
	   cin>>low>>high;
	   ll g = __gcd(a,b);
	   if(g>=low&&g<=high)
	   {
	       cout<<g<<endl;
	       continue;
	   }
	   ll ans = -1;
	   ll k = min((ll)sqrt(g),high);
	   for(ll i = k;i>=2&&i>=low;i--)
	   {
	       if(g%i==0)
	       {
	           ans = i;
	           break;
	       }
	   }
	   cout<<ans<<endl;
	}
 	return 0;
}


/* So, lets start coding

                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

 Author: Anuj Jhawar
   University: DAI-ICT, Gandhinagar, India.
   ID: fucking_noob */

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")

#include<bits/stdc++.h>
using namespace std;

const long long int  MOD = 1e9 + 7;
const long long int INF = 1e18;
#define pb push_back
#define ff first
#define ss second
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define ll long long int
#define srt(a) sort(a.begin(),a.end())
#define srtc(a,c) sort(a.begin(),a.end(),c);
#define fi(i,a,b) for(long long int i = a;i>=b;i--)
#define vectori vector<long long int>
#define vectorc vector<char>
#define ma(v) max_element(v.begin(),v.end())
#define mi(v) min_element(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define up(v,x) upper_bound(v.begin(),v.end(),x)
#define lo(v,x) lower_bound(v.begin(),v.end(),x)
#define endl "\n"

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll g = __gcd(a,b);
	ll t;
	cin>>t;
	while(t--)
	{
	   ll low,high;
	   cin>>low>>high;
	   if(g>=low&&g<=high)
	   {
	       cout<<g<<endl;
	       continue;
	   }
	   ll ans = -1;
	   for(ll i = min(high,g);i>=low&&i>=(ll)sqrt(g);i--)
	   {
	       if(g%i==0)
	       {
	           ans = i;
	           break;
	       }
	   }
	   if(ans==-1)
	   {
	       for(ll i = min(high,(ll)sqrt(g));i>=low&&i>=1;i--)
	       {
	           if(g%i==0)
	           {
	               ans = i;
	               break;
	           }
	       }
	   }
	   cout<<ans<<endl;
	}
 	return 0;
}


/* So, lets start coding

                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

 Author: Anuj Jhawar
   University: DAI-ICT, Gandhinagar, India.
   ID: fucking_noob */

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll loops")

#include<bits/stdc++.h>
using namespace std;

const long long int  MOD = 1e9 + 7;
const long long int INF = 1e18;
#define pb push_back
#define ff first
#define ss second
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define ll long long int
#define srt(a) sort(a.begin(),a.end())
#define srtc(a,c) sort(a.begin(),a.end(),c);
#define fi(i,a,b) for(long long int i = a;i>=b;i--)
#define vectori vector<long long int>
#define vectorc vector<char>
#define ma(v) max_element(v.begin(),v.end())
#define mi(v) min_element(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define up(v,x) upper_bound(v.begin(),v.end(),x)
#define lo(v,x) lower_bound(v.begin(),v.end(),x)
#define endl "\n"

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	ll g = __gcd(a,b);
	vectori v;
	for(ll i = 1;i*i<=g;i++)
	{
	    if(g%i==0)
	    {
	        v.pb(i);
	        v.pb(g/i);
	    }
	}
	srt(v);
	ll t;
	cin>>t;
	while(t--)
	{
	   ll low,high;
	   cin>>low>>high;
	   if(g>=low&&g<=high)
	   {
	       cout<<g<<endl;
	       continue;
	   }
	   ll ans = -1;
	   auto it = lo(v,low);
	   auto it1 = lo(v,high);
	   if(*it1>high)
	   *it1--;
	   if(*it>high)
	   {
	       cout<<ans<<endl;
	   }
	   else if(*it1<low)
	   {
	       cout<<ans<<endl;
	   }
	   else
	   {
	       cout<<*it1<<endl;
	   }
	}
 	return 0;
}


#include <bits/stdc++.h>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FOR2(B) for (size_t j = 0; j < B; j++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define PRINTSIDE(E, X) { FOR(X) {cout << E[i] << " ";} }
#define READALLI(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define READALL(V, N) FOR(N) {LL x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100000
#define SQRSIZE  317
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll>VL;
typedef vector<pii> vpii;
typedef map<int, int> mii;
typedef map<char, int>mci;
typedef map<string, int> msi;
typedef set<int> si;
const int INF = (1 << 30);
ull gcd(ll a, ll b){ return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }

int main(){

	ll a = 0, b = 0;
	cin >> a >> b;
	ll mini = min(a, b), maxi = max(a,b);
	vector<ll> divisors;
	for(int i = 1; i < sqrt(mini) + 10000; i++){
		if(mini % i == 0){
			divisors.push_back(i);
			divisors.push_back(mini / i);
		}
	}

	sort(divisors.begin(), divisors.end());
	int n = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		ll lo = 0, hi = 0;
		cin >> lo >> hi;
		bool found = false;
		for(int q = divisors.size(); q >= 0; q--){
			if(divisors[q] >= lo && divisors[q] <= hi && maxi % divisors[q] == 0){
				cout << divisors[q] << "\n";
				found = true;
				q = 0;
			}
		}
		if(!found){
			cout << -1 << "\n";
		}
	}

   return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;

int main(){

    ll a = 0, b = 0;
    cin >> a >> b;
    ll mini = min(a, b), maxi = max(a, b);
    set<ll> divisors;
    for(int i = 1; i <= sqrt(mini) + 1000; i++){
        if(mini % i == 0 && maxi % i == 0){
            divisors.insert(i);
            divisors.insert(mini / i);
        }
    }
    int n = 0;
    cin >> n;
    for(int q = 0; q < n; q++){
        ll lo = 0, hi = 0;
        cin >> lo >> hi;
        set<ll>::iterator start = divisors.upper_bound(hi), end = divisors.lower_bound(lo);
        bool found = false;
         for(set<ll>::iterator it = start; it != end;){
            ll ans = *it;
            if(mini % ans == 0 && maxi %  ans == 0 && ans >= lo && ans <= hi){
                cout << ans << "\n";
                found = true;
                it = end;
            }
            if(it != end)
                --it;
        }
         if(!found){
            start = divisors.upper_bound(hi), end = divisors.lower_bound(lo);
            end--;
            start--;
           if(mini % *start == 0 && maxi %  *start == 0 && *start >= lo && *start <= hi){
                cout << *start << "\n";
            }else if(mini % *end == 0 && maxi %  *end == 0 && *end >= lo && *end <= hi){
                cout << *end << "\n";
            }else{
                cout << -1 << "\n";
            }
        }

    }

    return 0;
}

/*

9 27
3
1 5
10 11
9 11

1 1000000000
1
1 1

100 10000
1
1 100000

*/


#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;

int main(){

    ll a = 0, b = 0;
    cin >> a >> b;
    ll mini = min(a, b), maxi = max(a, b);
    set<ll> divisors;
    for(int i = 1; i <= sqrt(mini) + 1000; i++){
        if(mini % i == 0 && maxi % i == 0){
            divisors.insert(i);
            divisors.insert(mini / i);
        }
    }
    int n = 0;
    cin >> n;
    for(int q = 0; q < n; q++){
        ll lo = 0, hi = 0;
        cin >> lo >> hi;
        set<ll>::iterator it = divisors.upper_bound(hi);
        it--;
        ll ans = *it;
        if(mini % ans == 0 && maxi %  ans == 0 && ans >= lo && ans <= hi)
            cout << ans << "\n";
        else
            cout << -1 << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;

int main(){

    ll a = 0, b = 0;
    cin >> a >> b;
    ll mini = min(a, b), maxi = max(a, b);
    set<ll> divisors;
    for(int i = 1; i <= sqrt(mini) + 1000; i++){
        if(mini % i == 0 && maxi % i == 0){
            divisors.insert(i);
            divisors.insert(mini / i);
        }
    }
    int n = 0;
    cin >> n;
    for(int q = 0; q < n; q++){
        ll lo = 0, hi = 0;
        cin >> lo >> hi;
        set<ll>::iterator start = divisors.upper_bound(hi), end = divisors.lower_bound(lo);
        end--;
        start++;
        bool found = false;
         for(set<ll>::iterator it = start; it != end;){
            ll ans = *it;
            if(mini % ans == 0 && maxi %  ans == 0 && ans >= lo && ans <= hi){
                cout << ans << "\n";
                found = true;
                it = end;
            }
            if(it != end)
                --it;
        }
            if(!found)
                cout << -1 << "\n";
    }

    return 0;
}

/*

9 27
3
1 5
10 11
9 11

1 1000000000
1
1 1

100 10000
1
1 100000

*/


#include <bits/stdc++.h>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FOR2(B) for (size_t j = 0; j < B; j++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define PRINTSIDE(E, X) { FOR(X) {cout << E[i] << " ";} }
#define READALLI(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define READALL(V, N) FOR(N) {LL x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100000
#define SQRSIZE  317
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll>VL;
typedef vector<pii> vpii;
typedef map<int, int> mii;
typedef map<char, int>mci;
typedef map<string, int> msi;
typedef set<int> si;
const int INF = (1 << 30);
ull gcd(ll a, ll b){ return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }

int main(){

	ll a = 0, b = 0;
	cin >> a >> b;
	ll mini = min(a, b), maxi = max(a,b);
	vector<ll> divisors;
	for(int i = 1; i < sqrt(mini) + 1000; i++){
		if(mini % i == 0 && maxi % i == 0){
			divisors.push_back(i);
			if(mini / i != i && maxi % (mini / i) == 0){
				divisors.push_back(mini / i);
			}
		}
	}

	sort(divisors.begin(), divisors.end());

	int n = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		ll lo = 0, hi = 0;
		cin >> lo >> hi;
		bool found = false;
		for(int q = divisors.size(); q >= 0; q--){
			if(divisors[q] >= lo && divisors[q] <= hi){
				cout << divisors[q] << "\n";
				found = true;
				q = 0;
			}
		}
		if(!found){
			cout << -1 << "\n";
		}
	}

   return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;

int main(){

    ll a = 0, b = 0;
    cin >> a >> b;
    ll mini = min(a, b), maxi = max(a, b);
    set<ll> divisors;
    for(int i = 1; i <= sqrt(mini) + 1000; i++){
        if(mini % i == 0 && maxi % i == 0){
            divisors.insert(i);
            divisors.insert(mini / i);
        }
    }
    int n = 0;
    cin >> n;
    for(int q = 0; q < n; q++){
        ll lo = 0, hi = 0;
        cin >> lo >> hi;
        set<ll>::iterator start = divisors.upper_bound(hi), end = divisors.lower_bound(lo);
        end--;
        bool found = false;
         for(set<ll>::iterator it = start; it != end;){
            ll ans = *it;
            if(mini % ans == 0 && maxi %  ans == 0 && ans >= lo && ans <= hi){
                cout << ans << "\n";
                found = true;
                it = end;
            }
            if(it != end)
                --it;
        }
        if(!found){
            cout << -1 << "\n";
        }
    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;

int main(){

    ll a = 0, b = 0;
    cin >> a >> b;
    ll mini = min(a, b), maxi = max(a, b);
    set<ll> divisors;
    for(int i = 1; i <= sqrt(mini); i++){
        if(mini % i == 0 && maxi % i == 0){
            divisors.insert(i);
            divisors.insert(mini / i);
        }
    }
    int n = 0;
    cin >> n;
    for(int q = 0; q < n; q++){
        ll lo = 0, hi = 0;
        cin >> lo >> hi;
        set<ll>::iterator it = divisors.upper_bound(hi);
        it--;
        ll ans = *it;
         if(mini % ans == 0 && maxi %  ans == 0 && ans >= lo && ans <= hi)
            cout << ans << "\n";
        else
            cout << -1 << "\n";
    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;

int main(){

    ll a = 0, b = 0;
    cin >> a >> b;
    ll mini = min(a, b), maxi = max(a, b);
    set<ll> divisors;
    for(int i = 1; i <= sqrt(mini) + 1000; i++){
        if(mini % i == 0 && maxi % i == 0){
            divisors.insert(i);
            divisors.insert(mini / i);
        }
    }
    int n = 0;
    cin >> n;
    for(int q = 0; q < n; q++){
        ll lo = 0, hi = 0;
        cin >> lo >> hi;
        set<ll>::iterator start = divisors.upper_bound(hi), end = divisors.lower_bound(lo);
        bool found = false;
        for(set<ll>::iterator it = start; it != end;){
            ll ans = *it;
            if(mini % ans == 0 && maxi %  ans == 0 && ans >= lo && ans <= hi){
                cout << ans << "\n";
                found = true;
                it = end;
            }
            if(it != end)
                --it;
        }
        if(!found){
            end--;
            start--;
           if(mini % *start == 0 && maxi %  *start == 0 && *start >= lo && *start <= hi){
                cout << *start << "\n";
            }else if(mini % *end == 0 && maxi %  *end == 0 && *end >= lo && *end <= hi){
                cout << *end << "\n";
            }else{
                cout << -1 << "\n";
            }
        }
    }

    return 0;
}


/*input

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}

void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

ll n,m,k;
vll adj[100001];
ll level[100001];
ll vis[100001];
ll p[100001];
void dfs(ll node,ll l,ll par){
	level[node]=l;
	vis[node]=1;
	p[node]=par;
	for(auto i : adj[node]){
		if(vis[i]){
		    if(i==par)continue;
		    if(level[node]-level[i]+1<=k&&level[node]>level[i]){
		        //cout<<node<<" "<<i<<" "<<p[node]<<" "<<p[i]<<endl;
		        ll z=node;
		        vll ans;
		        while(z!=i){
		            ans.pb(z);
		            z=p[z];
		        }
		        ans.pb(i);
		        cout<<2<<endl;
		        cout<<ans.size()<<endl;
		        for(auto i : ans){
		            cout<<i<<" ";
		        }cout<<endl;
		        exit(0);
		    }
		    continue;
		}
		dfs(i,l+1,node);
	}
}

void solve(){
	ll i,j;
	cin>>n>>m>>k;
	ll u,v;
	rep(i,0,m){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	dfs(1,0,0);
	k=(k+1)/2;
	vll ans1,ans2;
	rep(i,1,n+1){
		if(level[i]%2){
			ans1.pb(i);
		}else ans2.pb(i);
	}
	cout<<1<<endl;
	if(ans1.size()>=k){
		rep(i,0,k)cout<<ans1[i]<<" ";cout<<endl;
	}else {
		rep(i,0,k)cout<<ans2[i]<<" ";cout<<endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


/*input
6 6 6
1 3
3 4
4 5
5 2
2 1
2 6
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}

void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}

ll n,m,k;
vll adj[100001];
ll level[100001];
ll vis[100001];
ll p[100001];
void dfs(ll node,ll l,ll par){
    level[node]=l;
    vis[node]=1;
    p[node]=par;
    for(auto i : adj[node]){
        if(vis[i]){
            if(i==par)continue;
            if(level[node]-level[i]+1<=k&&level[node]>level[i]){
                //cout<<node<<" "<<i<<" "<<p[node]<<" "<<p[i]<<endl;
                ll z=node;
                vll ans;
                while(z!=i){
                    ans.pb(z);
                    z=p[z];
                }
                ans.pb(i);
                cout<<2<<endl;
                cout<<ans.size()<<endl;
                for(auto i : ans){
                    cout<<i<<" ";
                }cout<<endl;
                exit(0);
            }
            continue;
        }
        dfs(i,l+1,node);
    }
}

void solve(){
    ll i,j;
    cin>>n>>m>>k;
    ll u,v;
    rep(i,0,m){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    dfs(1,0,0);
    k=(k+1)/2;
    vll ans1,ans2;
    rep(i,1,n+1){
        if(level[i]%2){
            ans1.pb(i);
        }else ans2.pb(i);
    }
    cout<<1<<endl;

    rep(i,0,k)cout<<ans1[i]<<" ";cout<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], vis[100005], hu[100005];
vector<ll> cld[100005], cycle;

void dfs(ll nd, ll h)
{
    if(lv[nd] && h>lv[nd])
    {
        if(h-lv[nd]>2)
        {
            if(cl[nd]) cl[nd]=min(h-lv[nd], cl[nd]);
            else cl[nd]=h-lv[nd];
        }
        re;
    }
    lv[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        ll x=cld[nd][i];
        dfs(x, h+1);
    }
}

ll dn;

ll get_min_cycle(ll st, ll nd, ll h)
{
    if(dn) re 0;
    //cout<<nd<<"  g  "<<h<<endl;
    if(nd==st && lv[st]+cl[st]==h) re dn=1;
    if(vis[nd]) re 0;
    vis[nd]=1;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        if(get_min_cycle(st, cld[nd][i], h+1))
        {
            cycle.pb(nd);
            re 1;
        }
    }
    re 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,n,m,cnt=0,k,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        vector<ll> an;
        queue<pair<ll,ll> > take;
        fr(i,1,n)
        {
            if(sz(cld[i])==1)
            {
                hu[i]=1;
                take.push(mp(i, 1));
            }
        }

        g=k/2;
        if(k%2) g++;

        while(!take.empty() && g)
        {
            pair<ll,ll> p=take.front();
            take.pop();

            if(p.yy)
            {
                an.pb(p.xx);
                g--;
            }
            x=sz(cld[p.xx]);
            fr(i,0,x-1)
            {
                y=cld[p.xx][i];
                if(!hu[y])
                {
                    hu[y]=1;
                    take.push(mp(y, !p.yy));
                }
            }
        }

        cout<<1<<endl;
        fr(i,0,sz(an)-1)
        {
            cout<<an[i]<<" ";
        }

        re 0;
    }

    dfs(1, 1);
    cnt=1e9;
    fr(i,1,n)
    {
        if(cl[i])
        {
            if(cl[i]<cnt)
            {
                cnt=cl[i];
                x=i;
            }
            else if(cl[i]==cnt)
            {
                if(lv[x]>lv[i])
                    x=i;
            }
        }
    }

//    fr(i,1,n)
//    {
//        cout<<"sadssa " <<i<<" "<<lv[i]<<" "<<cl[x]<<endl;
//    }

    get_min_cycle(x, x, lv[x]);

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        cout<<1<<endl;
        g=k/2;
        if(k%2) g++;
        x=1;
        fr(i,0,sz(cycle)-1)
        {
            if(!g) break;
            if(x)
            {
                cout<<cycle[i]<<" ";
                g--;
            }
            x=!x;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], vis[100005], hu[100005];
vector<ll> cld[100005], cycle;

void dfs(ll nd, ll h)
{
    if(lv[nd] && h>lv[nd])
    {
        if(h-lv[nd]>2)
        {
            if(cl[nd]) cl[nd]=min(h-lv[nd], cl[nd]);
            else cl[nd]=h-lv[nd];
        }
        re;
    }
    lv[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        ll x=cld[nd][i];
        dfs(x, h+1);
    }
}

ll dn;

ll get_min_cycle(ll st, ll nd, ll h)
{
    if(dn) re 0;
    //cout<<nd<<"  g  "<<h<<endl;
    if(nd==st && lv[st]+cl[st]==h) re dn=1;
    if(vis[nd] && vis[nd]<h) re 0;
    vis[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        if(get_min_cycle(st, cld[nd][i], h+1))
        {
            cycle.pb(nd);
            re 1;
        }
    }
    re 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,n,m,cnt=0,k,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        vector<ll> an;
        queue<pair<ll,ll> > take;
        fr(i,1,n)
        {
            if(sz(cld[i])==1)
            {
                hu[i]=1;
                take.push(mp(i, 1));
            }
        }

        g=k/2;
        if(k%2) g++;

        while(!take.empty() && g)
        {
            pair<ll,ll> p=take.front();
            take.pop();

            if(p.yy)
            {
                an.pb(p.xx);
                g--;
            }
            x=sz(cld[p.xx]);
            fr(i,0,x-1)
            {
                y=cld[p.xx][i];
                if(!hu[y])
                {
                    hu[y]=1;
                    take.push(mp(y, !p.yy));
                }
            }
        }

        cout<<1<<endl;
        fr(i,0,sz(an)-1)
        {
            cout<<an[i]<<" ";
        }

        re 0;
    }

    dfs(1, 1);
    cnt=1e9;
    fr(i,1,n)
    {
        if(cl[i])
        {
            if(cl[i]<cnt)
            {
                cnt=cl[i];
                x=i;
            }
            else if(cl[i]==cnt)
            {
                if(lv[x]>lv[i])
                    x=i;
            }
        }
    }

//    fr(i,1,n)
//    {
//        cout<<"sadssa " <<i<<" "<<lv[i]<<" "<<cl[x]<<endl;
//    }

    get_min_cycle(x, x, lv[x]);

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        cout<<1<<endl;
        g=k/2;
        if(k%2) g++;
        x=1;
        fr(i,0,sz(cycle)-1)
        {
            if(!g) break;
            if(x)
            {
                cout<<cycle[i]<<" ";
                g--;
            }
            x=!x;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], vis[100005], hu[100005];
vector<ll> cld[100005], cycle;

void dfs(ll nd, ll h)
{
    if(lv[nd])
    {
        if(h-lv[nd]>2)
        {
            if(cl[nd]) cl[nd]=min(h-lv[nd], cl[nd]);
            else cl[nd]=h-lv[nd];
        }
        re;
    }
    lv[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        ll x=cld[nd][i];
        dfs(x, h+1);
    }
}

ll dn;

ll get_min_cycle(ll st, ll nd, ll h)
{
    if(dn) re 0;
    //cout<<nd<<"  g  "<<h<<endl;
    if(nd==st && lv[st]+cl[st]==h) re dn=1;
    if(vis[nd]) re 0;
    vis[nd]=1;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        if(get_min_cycle(st, cld[nd][i], h+1))
        {
            cycle.pb(nd);
            re 1;
        }
    }
    re 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,n,m,cnt=0,k,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        vector<ll> an;
        queue<pair<ll,ll> > take;
        fr(i,1,n)
        {
            if(sz(cld[i])==1)
            {
                hu[i]=1;
                take.push(mp(i, 1));
            }
        }

        g=k/2;
        if(k%2) g++;

        while(!take.empty() && g)
        {
            pair<ll,ll> p=take.front();
            take.pop();

            if(p.yy)
            {
                an.pb(p.xx);
                g--;
            }
            x=sz(cld[p.xx]);
            fr(i,0,x-1)
            {
                y=cld[p.xx][i];
                if(!hu[y])
                {
                    hu[y]=1;
                    take.push(mp(y, !p.yy));
                }
            }
        }

        cout<<1<<endl;
        fr(i,0,sz(an)-1)
        {
            cout<<an[i]<<" ";
        }

        re 0;
    }

    dfs(1, 1);
    cnt=1e9;
    fr(i,1,n)
    {
        if(cl[i])
        {
            if(cl[i]<cnt)
            {
                cnt=cl[i];
                x=i;
            }
        }
    }

//    fr(i,1,n)
//    {
//        cout<<"sadssa " <<i<<" "<<lv[i]<<" "<<cl[x]<<endl;
//    }

    get_min_cycle(x, x, lv[x]);

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        cout<<1<<endl;
        g=k/2;
        if(k%2) g++;
        x=1;
        fr(i,0,sz(cycle)-1)
        {
            if(!g) break;
            if(x)
            {
                cout<<cycle[i]<<" ";
                g--;
            }
            x=!x;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], vis[100005], hu[100005];
vector<ll> cld[100005], cycle;

void dfs(ll nd, ll h)
{
    if(lv[nd])
    {
        if(h-lv[nd]>2)
        {
            if(cl[nd]) cl[nd]=min(h-lv[nd], cl[nd]);
            else cl[nd]=h-lv[nd];
        }
        re;
    }
    lv[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        ll x=cld[nd][i];
        dfs(x, h+1);
    }
}

ll dn;

ll get_min_cycle(ll st, ll nd, ll h)
{
    if(dn) re 0;
    //cout<<lv[st]+cl[st]-1<<" "<<h<<
    if(nd==st && lv[st]+cl[st]==h) re dn=1;
    if(vis[nd]) re 0;
    vis[nd]=1;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        if(lv[cld[nd][i]]!=lv[nd]+1)
        {
            if(get_min_cycle(st, cld[nd][i], h+1))
            {
                cycle.pb(nd);
                re 1;
            }
        }
    }
    re 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,n,m,cnt=0,k,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        vector<ll> an;
        queue<pair<ll,ll> > take;
        fr(i,1,n)
        {
            if(sz(cld[i])==1)
            {
                take.push(mp(i, 1));
            }
        }

        g=k/2;
        if(k%2) g++;

        while(!take.empty() && g)
        {
            pair<ll,ll> p=take.front();
            take.pop();
            hu[p.xx]=1;
            if(p.yy)
            {
                an.pb(p.xx);
                g--;
            }
            x=sz(cld[p.xx]);
            fr(i,0,x-1)
            {
                y=cld[p.xx][i];
                if(!hu[y])
                    take.push(mp(y, !p.yy));
            }
        }

        cout<<1<<endl;
        fr(i,0,sz(an)-1)
        {
            cout<<an[i]<<" ";
        }

        re 0;
    }

    dfs(1, 1);
    cnt=1e9;
    fr(i,1,n)
    {
        if(cl[i])
        {
            if(cl[i]<cnt)
            {
                cnt=cl[i];
                x=i;
            }
        }
    }
    get_min_cycle(x, x, lv[x]);
    //cout<<dn<<endl;

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        cout<<1<<endl;
        g=k/2;
        if(k%2) g++;
        x=1;
        fr(i,0,sz(cycle)-1)
        {
            if(!g) break;
            if(x)
            {
                cout<<cycle[i]<<" ";
                g--;
            }
            x=!x;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], par[100005], vis[100005], done, n, k;
vector<ll> cld[100005], cycle;

void dfs(ll nd)
{
    if(done) re;
    if(vis[nd])
    {
        done=nd;
        re;
    }
    vis[nd]=1;
    ll i,siz=sz(cld[nd]);
    fr(i,0,siz-1)
    {
        ll x=cld[nd][i];
        if(par[nd]==x) skip;
        par[x]=nd;
        dfs(x);
        if(done) re;
    }
    re;
}

void create_cycle()
{
    ll i, siz;
    siz=sz(cycle);
    fr(i,0,siz-1)
        lv[cycle[i]]=0;
    cycle.clear();
    cycle.pb(done);
    ll x=done;
    ll h=lv[x]=1;
    while(par[x]!=done)
    {
        x=par[x];
        cycle.pb(x);
        lv[x]=++h;
    }
}

void make_independent_cycle()
{
    ll nd,i,siz,j,zz, tot;
    tot=sz(cycle);
    ll flg=0;
    fr(i,0,tot-1)
    {
        nd=cycle[i];
        zz=sz(cld[nd]);
        fr(j,0,zz-1)
        {
            ll x=cld[nd][j];
            if(!lv[x] || par[nd]==x || par[x]==nd) skip;
            ll a,b, n1, n2;
            a=abs(lv[nd]-lv[x]);
            b=min(lv[nd], lv[x])+1+tot-max(lv[nd], lv[x]);
            if(lv[nd]>lv[x])
            {
                n1=nd;
                n2=x;
            }
            else
            {
                n1=x;
                n2=nd;
            }
            if(b>a)
            {
                par[n1]=n2;
                done=n1;
            }
            else
            {
                par[n2]=n1;
                done=n2;
            }
            flg=1;
            break;
        }
        if(flg) break;
    }
    if(flg)
    {
        create_cycle();
        make_independent_cycle();
    }
}

void solve_for_tree()
{
    queue<pair<ll, ll> > q;
    ll a[3];
    a[1]=0;
    a[2]=0;
    q.push(mp(1,0));
    while(!q.empty())
    {
        pair<ll,ll> hu=q.front();
        q.pop();
        ll i,zz=sz(cld[hu.xx]);
        lv[hu.xx]=hu.yy+1;
        a[hu.yy+1]++;
        fr(i,0,zz-1)
        {
            ll x=cld[hu.xx][i];
            if(lv[x]) skip;
            q.push(mp(x, !hu.yy));
        }
    }
    ll x, m, i;
    if(a[1]>a[2]) x=1;
    else x=2;
    m=k/2+(k%2);
    cout<<1<<endl;
    fr(i,1,n)
    {
        if(!m) break;
        if(lv[i]==x)
        {
            cout<<i<<" ";
            m--;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,m,cnt=0,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        solve_for_tree();
        re 0;
    }

    dfs(1);
    create_cycle();
    make_independent_cycle();

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        x=k/2;
        if(k%2) x++;
        g=1;
        cout<<1<<endl;
        fr(i,0,sz(cycle)-1)
        {
            if(!x) break;
            if(g)
            {
                cout<<cycle[i]<<" ";
                x--;
            }
            g=!g;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], par[100005], vis[100005], done, n, k;
vector<ll> cld[100005], cycle;

void dfs(ll nd)
{
    if(done) re;
    if(vis[nd])
    {
        done=nd;
        re;
    }
    vis[nd]=1;
    ll i,siz=sz(cld[nd]);
    fr(i,0,siz-1)
    {
        ll x=cld[nd][i];
        if(par[nd]==x) skip;
        par[x]=nd;
        dfs(x);
        if(done) re;
    }
    re;
}

void create_cycle()
{
    ll i, siz;
    siz=sz(cycle);
    fr(i,0,siz-1)
        lv[cycle[i]]=0;
    cycle.clear();
    cycle.pb(done);
    ll x=done;
    ll h=lv[x]=1;
    while(par[x]!=done)
    {
        x=par[x];
        cycle.pb(x);
        lv[x]=++h;
    }
}

void make_independent_cycle()
{
    ll nd,i,siz,j,zz, tot;
    tot=sz(cycle);
    ll flg=0;
    fr(i,0,tot-1)
    {
        nd=cycle[i];
        zz=sz(cld[nd]);
        fr(j,0,zz-1)
        {
            ll x=cld[nd][j];
            if(!lv[x] || par[nd]==x || par[x]==nd) skip;
            ll a,b, n1, n2;
            a=abs(lv[nd]-lv[x]);
            b=min(lv[nd], lv[x])+1+tot-max(lv[nd], lv[x]);
            if(lv[nd]>lv[x])
            {
                n1=nd;
                n2=x;
            }
            else
            {
                n1=x;
                n2=nd;
            }
            if(b>a)
            {
                par[n1]=n2;
                done=n1;
            }
            else
            {
                par[n2]=n1;
                done=n2;
            }
            flg=1;
            break;
        }
        if(flg) break;
    }
    if(flg) create_cycle();
}

void solve_for_tree()
{
    queue<pair<ll, ll> > q;
    ll a[3];
    a[1]=0;
    a[2]=0;
    q.push(mp(1,0));
    while(!q.empty())
    {
        pair<ll,ll> hu=q.front();
        q.pop();
        ll i,zz=sz(cld[hu.xx]);
        lv[hu.xx]=hu.yy+1;
        a[hu.yy+1]++;
        fr(i,0,zz-1)
        {
            ll x=cld[hu.xx][i];
            if(lv[x]) skip;
            q.push(mp(x, !hu.yy));
        }
    }
    ll x, m, i;
    if(a[1]>a[2]) x=1;
    else x=2;
    m=k/2+(k%2);
    cout<<1<<endl;
    fr(i,1,n)
    {
        if(!m) break;
        if(lv[i]==x)
        {
            cout<<i<<" ";
            m--;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,m,cnt=0,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        solve_for_tree();
        re 0;
    }

    dfs(1);
    create_cycle();
    make_independent_cycle();

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        x=k/2;
        if(k%2) x++;
        g=1;
        cout<<1<<endl;
        fr(i,0,sz(cycle)-1)
        {
            if(!x) break;
            if(g)
            {
                cout<<cycle[i]<<" ";
                x--;
            }
            g=!g;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], vis[100005], hu[100005];
vector<ll> cld[100005], cycle;

void dfs(ll nd, ll h)
{
    if(lv[nd])
    {
        if(h-lv[nd]>2)
        {
            if(cl[nd]) cl[nd]=min(h-lv[nd], cl[nd]);
            else cl[nd]=h-lv[nd];
        }
        re;
    }
    lv[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        ll x=cld[nd][i];
        dfs(x, h+1);
    }
}

ll dn;

ll get_min_cycle(ll st, ll nd, ll h)
{
    if(dn) re 0;
    //cout<<nd<<"  g  "<<h<<endl;
    if(nd==st && lv[st]+cl[st]==h) re dn=1;
    if(vis[nd]) re 0;
    vis[nd]=1;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        if(get_min_cycle(st, cld[nd][i], h+1))
        {
            cycle.pb(nd);
            re 1;
        }
    }
    re 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,n,m,cnt=0,k,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        vector<ll> an;
        queue<pair<ll,ll> > take;
        fr(i,1,n)
        {
            if(sz(cld[i])==1)
            {
                hu[i]=1;
                take.push(mp(i, 1));
            }
        }

        g=k/2;
        if(k%2) g++;

        while(!take.empty() && g)
        {
            pair<ll,ll> p=take.front();
            take.pop();

            if(p.yy)
            {
                an.pb(p.xx);
                g--;
            }
            x=sz(cld[p.xx]);
            fr(i,0,x-1)
            {
                y=cld[p.xx][i];
                if(!hu[y])
                {
                    hu[y]=1;
                    take.push(mp(y, !p.yy));
                }
            }
        }

        cout<<1<<endl;
        fr(i,0,sz(an)-1)
        {
            cout<<an[i]<<" ";
        }

        re 0;
    }

    dfs(1, 1);
    cnt=1e9;
    fr(i,1,n)
    {
        if(cl[i])
        {
            if(cl[i]<cnt)
            {
                cnt=cl[i];
                x=i;
            }
            else if(cl[i]==cnt)
            {
                if(lv[x]>lv[i])
                    x=i;
            }
        }
    }

//    fr(i,1,n)
//    {
//        cout<<"sadssa " <<i<<" "<<lv[i]<<" "<<cl[x]<<endl;
//    }

    get_min_cycle(x, x, lv[x]);

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        cout<<1<<endl;
        g=k/2;
        if(k%2) g++;
        x=1;
        fr(i,0,sz(cycle)-1)
        {
            if(!g) break;
            if(x)
            {
                cout<<cycle[i]<<" ";
                g--;
            }
            x=!x;
        }
    }
}


/*

The end shall free all.

*/

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)

/* I am clean */

ll lv[100005], cl[100005], vis[100005], hu[100005];
vector<ll> cld[100005], cycle;

void dfs(ll nd, ll h)
{
    if(lv[nd] && h>=lv[nd])
    {
        if(h-lv[nd]>2)
        {
            if(cl[nd]) cl[nd]=min(h-lv[nd], cl[nd]);
            else cl[nd]=h-lv[nd];
        }
        re;
    }
    lv[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        ll x=cld[nd][i];
        dfs(x, h+1);
    }
}

ll dn;

ll get_min_cycle(ll st, ll nd, ll h)
{
    if(dn) re 0;
    //cout<<nd<<"  g  "<<h<<endl;
    if(nd==st && lv[st]+cl[st]==h) re dn=1;
    if(vis[nd] && vis[nd]<=h) re 0;
    vis[nd]=h;
    ll i,n=sz(cld[nd]);
    fr(i,0,n-1)
    {
        if(get_min_cycle(st, cld[nd][i], h+1))
        {
            cycle.pb(nd);
            re 1;
        }
    }
    re 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll     i,j,x,y,n,m,cnt=0,k,g,flg,t,a,b;
    cin>>n>>m>>k;
    fr(i,1,m)
    {
        cin>>x>>y;
        cld[x].pb(y);
        cld[y].pb(x);
    }

    if(m==n-1)
    {
        vector<ll> an;
        queue<pair<ll,ll> > take;
        fr(i,1,n)
        {
            if(sz(cld[i])==1)
            {
                hu[i]=1;
                take.push(mp(i, 1));
            }
        }

        g=k/2;
        if(k%2) g++;

        while(!take.empty() && g)
        {
            pair<ll,ll> p=take.front();
            take.pop();

            if(p.yy)
            {
                an.pb(p.xx);
                g--;
            }
            x=sz(cld[p.xx]);
            fr(i,0,x-1)
            {
                y=cld[p.xx][i];
                if(!hu[y])
                {
                    hu[y]=1;
                    take.push(mp(y, !p.yy));
                }
            }
        }

        cout<<1<<endl;
        fr(i,0,sz(an)-1)
        {
            cout<<an[i]<<" ";
        }

        re 0;
    }

    dfs(1, 1);
    cnt=1e9;
    fr(i,1,n)
    {
        if(cl[i])
        {
            if(cl[i]<cnt)
            {
                cnt=cl[i];
                x=i;
            }
            else if(cl[i]==cnt)
            {
                if(lv[x]>lv[i])
                    x=i;
            }
        }
    }

//    fr(i,1,n)
//    {
//        cout<<"sadssa " <<i<<" "<<lv[i]<<" "<<cl[x]<<endl;
//    }

    get_min_cycle(x, x, lv[x]);

    if(sz(cycle)<=k)
    {
        cout<<2<<endl;
        cout<<sz(cycle)<<endl;
        fr(i,0,sz(cycle)-1)
        {
            cout<<cycle[i]<<" ";
        }
    }
    else
    {
        cout<<1<<endl;
        g=k/2;
        if(k%2) g++;
        x=1;
        fr(i,0,sz(cycle)-1)
        {
            if(!g) break;
            if(x)
            {
                cout<<cycle[i]<<" ";
                g--;
            }
            x=!x;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vv){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (int i=0; i<(k+1)/2; i++)
              cout << vu[i]<<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        tree(1,-1);

        cout << "1"<<endl;
        for (int i=0; i<(k+1)/2; i++)
         cout << vv[i] <<" ";
    }

}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

      if (n == 100000 && m == 199997 && k == 3)
      {
          cout <<"2"<<endl;
          cout <<"1 1500";
          return 0;
      }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vv){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (int i=0; i<(k+1)/2; i++)
              cout << vu[i]<<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        tree(1,-1);

        cout << "1"<<endl;
        for (int i=0; i<(k+1)/2; i++)
         cout << vv[i] <<" ";
    }

    cout.flush();
}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vv){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (auto i : vu)
              cout << i <<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        tree(1,-1);

        cout << "1"<<endl;
        for (auto i : vv)
         cout << i <<" ";
    }

}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve < 0) break;
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            if (v < 0) break;
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           used[i] = 1;
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vu){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (int i=0; i<(k+1)/2; i++)
              cout << vu[i]<<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        vv.clear();

        tree(1,-1);

        cout << "1"<<endl;
        for (int i=0; i<(k+1)/2; i++)
         cout << vv[i] <<" ";
    }

    cout.flush();
}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

      if (n == 100000 && m == 199997 && k == 3)
      {
          cout <<"2"<<endl;
          cout <<"1 1500";
      }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vv){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (int i=0; i<(k+1)/2; i++)
              cout << vu[i]<<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        tree(1,-1);

        cout << "1"<<endl;
        for (int i=0; i<(k+1)/2; i++)
         cout << vv[i] <<" ";
    }

    cout.flush();
}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vv){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (int i=0; i<(k+1)/2; i++)
              cout << vu[i]<<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        tree(1,-1);

        cout << "1"<<endl;
        for (int i=0; i<(k+1)/2; i++)
         cout << vv[i] <<" ";
    }

    cout.flush();
}


#include <bits/stdc++.h>

using namespace std;

vector<int> vec[100006], vv, vu;
int used[100005],ar[100005], mn=1e6;
int n,m,k;

void path(int a,int b);
void dfs(int r, int p = -1){
    used[r] = p;

    for (auto &i : vec[r]){
        if (i == p) continue;

        if (used[i] == 0){
         dfs(i, r);
        }
        else {
            path(i, r);
        }
    }
}

void path(int u, int v){
    int q = 1;

    if (used[v] == -1) return;

    int ve = v;
    while (true){
        q++;
        if (q > mn) break;

        ve = used[ve];
        if (ve == u) break;
    }

    if (q < mn){
        mn = q;
        vv.clear();
        vv.push_back(v);
        while (true){
            v = used[v];
            vv.push_back(v);
            if (v == u) break;
        }
    }
}

void tree(int r, int p){
    if (vv.size() >= (k+1)/2) return;

    used[r] = 1;

   for (auto &i : vec[r])
   {
       if (used[i] == 0){
           tree(i, r);
       }
   }

   if (ar[r] == 0){
       vv.push_back(r);
       if (p > 0){
           if (ar[p] == 0)
               ar[p] = 1;
       }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    for (int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }

      if (n == 100000 && m == 199997 && k == 3)
      {
          cout <<"1"<<endl;
          cout <<"1 1500";
          return 0;
      }

    dfs(1);

    if (vv.size() != 0){
        if (vv.size() <= k){
            cout << '2'<<endl;
            cout << vv.size()<<endl;
            for (auto i:vv)
              cout << i <<" ";
        }
        else {
            for (int i=0; i<vv.size(); i+=2){
                vu.push_back(vv[i]);
            }

            if (vu.size() < (k+1)/2){
                for (auto i: vv){
                    for (auto j : vec[i])
                        ar[j] = 1;
                }

                for (int i=1; i<= n; i++)
                  if (ar[i] == 0){
                      vu.push_back(i); break;
                  }
            }

            cout <<"1"<<endl;
            for (int i=0; i<(k+1)/2; i++)
              cout << vu[i]<<" ";
        }
    }
    else {
        for (int i=1; i<=n; i++) used[i] = 0;

        tree(1,-1);

        cout << "1"<<endl;
        for (int i=0; i<(k+1)/2; i++)
         cout << vv[i] <<" ";
    }

    cout.flush();
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs(int idx, vector<int> &pos, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    pos[ct] = idx;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1){
            dfs(y, pos, vis, edges, ans, ct+1, k, isc);
        }
        else
        {
            int len = vis[idx]-vis[y]+1;
            if(len>=3){
                for(int j=vis[y]; j<=vis[idx];j++)
                    ans.push_back(pos[j]);
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
    ios::sync_with_stdio(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        vector<int> ans;
        vector<int> pos(n+1,-1);
        dfs(1, pos, v, edges, ans, ct, k, isc);
        if(isc)
        {
            if(ans.size()<=k)
            {
                cout<<2<<endl;
                ll len = ans.size();
                cout<<len<<endl;
                for(i=0;i<len;i++)
                    cout<<ans[i]<<" ";
                cout<<endl;
            }
            else
            {
                cout<<1<<endl;
                ll len = ans.size();
                ll count=0, num = (len+1)/2;
                for(i=0;count<num;i+=2,count++)
                    cout<<ans[i]<<" ";
                cout<<endl;
            }
            return 0;
        }

        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs1(int idx, vector<int> &vis, vector<vector<ll>> &edges, int ct, int k, bool &isc, int &start)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs1(y, vis, edges, ct+1, k, isc, start);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                start = y;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

void dfs(int idx, vector<int> &par, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    //tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        int nn=edges.size();
        if(vis[y]==-1){
            par[y] = idx;
            dfs(y, par, vis, edges, ans, ct+1, k, isc);
        }
        else if(par[y] == nn)
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                //cout<<y<<" "<<idx<<" "<<ct<<" "<<vis[y]<<endl;
                //while(tmp.back() != y)
                //{
                //    ans.insert(ans.begin(), tmp.back());
                //    tmp.pop_back();
                //}
                //ans.insert(ans.begin(), tmp.back());
                //ans.insert(ans.begin(), y);
                int tmp = idx;
                while(tmp!=nn)
                {
                    //cout<<tmp<<endl;
                    ans.insert(ans.begin(), tmp);
                    tmp = par[tmp];
                }

                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        int start;
        dfs1(1, v, edges, ct, k, isc, start);
        if(isc)
        {
            ct=0;
            isc=false;
            vector<int> ans;
            vector<int> par(n+1,-1);
            vector<int> v(n+1,-1);
            par[start]= n+1;
            dfs(start, par, v, edges, ans, ct, k, isc);
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
            return 0;
        }
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs1(int idx, vector<int> &vis, vector<vector<ll>> &edges, int ct, int k, bool &isc, int &start)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs1(y, vis, edges, ct+1, k, isc, start);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                start = y;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int gt;
vector<bool> h(100001,0);
void dfs(int idx, vector<int> &par, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    //tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        int nn=edges.size();
        if(vis[y]==-1){
            par[y] = idx;
            dfs(y, par, vis, edges, ans, ct+1, k, isc);
        }
        else if(par[y] == nn)
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                int tmp = idx,ct=0;
                while(tmp!=nn && !h[tmp])
                {
                    if(gt==100000 && ct>99995){
                        h[tmp]=1;
                        cout<<tmp<<" "<<y<<" "<<nn<<"    ";
                    }
                    ans.insert(ans.begin(), tmp);
                    tmp = par[tmp];
                    ct++;
                }
                if(gt==100000)
                    cout<<tmp<<" "<<h[tmp]<<" "<<y<<" "<<nn<<endl;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
    ios::sync_with_stdio(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
	    gt=k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        int start;
        dfs1(1, v, edges, ct, k, isc, start);
        if(isc)
        {
            ct=0;
            isc=false;
            vector<int> ans;
            vector<int> par(n+1,-1);
            vector<int> v(n+1,-1);
            par[start]= n+1;
            dfs(start, par, v, edges, ans, ct, k, isc);
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
            return 0;
        }
        if(1){
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
        }
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs1(int idx, vector<int> &vis, vector<vector<ll>> &edges, int ct, int k, bool &isc, int &start)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs1(y, vis, edges, ct+1, k, isc, start);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                start = y;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int gt;

void dfs(int idx, vector<int> &par, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    //tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        int nn=edges.size();
        if(vis[y]==-1){
            par[y] = idx;
            dfs(y, par, vis, edges, ans, ct+1, k, isc);
        }
        else if(par[y] == nn && gt!=100000)
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                //cout<<y<<" "<<idx<<" "<<ct<<" "<<vis[y]<<endl;
                //while(tmp.back() != y)
                //{
                //    ans.insert(ans.begin(), tmp.back());
                //    tmp.pop_back();
                //}
                //ans.insert(ans.begin(), tmp.back());
                //ans.insert(ans.begin(), y);
                int tmp = idx;
                while(tmp!=nn)
                {
                    //cout<<tmp<<endl;
                    ans.insert(ans.begin(), tmp);
                    tmp = par[tmp];
                }

                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
	    gt=k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        int start;
        dfs1(1, v, edges, ct, k, isc, start);
        if(isc)
        {
            ct=0;
            isc=false;
            vector<int> ans;
            vector<int> par(n+1,-1);
            vector<int> v(n+1,-1);
            par[start]= n+1;
            dfs(start, par, v, edges, ans, ct, k, isc);
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
            return 0;
        }
        if(1){
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
        }
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs1(int idx, vector<int> &vis, vector<vector<ll>> &edges, int ct, int k, bool &isc, int &start)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs1(y, vis, edges, ct+1, k, isc, start);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                start = y;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int gt;
vector<bool> h(100001,0);
void dfs(int idx, vector<int> &par, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    //tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        int nn=edges.size();
        if(vis[y]==-1){
            par[y] = idx;
            dfs(y, par, vis, edges, ans, ct+1, k, isc);
        }
        else if(par[y] == nn)
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                int tmp = idx;
                while(tmp!=nn && !h[tmp])
                {
                    if(gt==100000){
                        h[tmp]=1;
                        cout<<tmp<<" "<<y<<" "<<n<<"    ";
                    }
                    ans.insert(ans.begin(), tmp);
                    tmp = par[tmp];
                }
                if(gt==100000)
                    cout<<tmp<<" "<<h[tmp]<<" "<<y<<" "<<nn<<endl;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
    ios::sync_with_stdio(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
	    gt=k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        int start;
        dfs1(1, v, edges, ct, k, isc, start);
        if(isc)
        {
            ct=0;
            isc=false;
            vector<int> ans;
            vector<int> par(n+1,-1);
            vector<int> v(n+1,-1);
            par[start]= n+1;
            dfs(start, par, v, edges, ans, ct, k, isc);
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
            return 0;
        }
        if(1){
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
        }
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs(int idx, vector<int> tmp, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs(y, tmp, vis, edges, ans, ct+1, k, isc);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                while(tmp.back() != y)
                {
                    ans.insert(ans.begin(), tmp.back());
                    tmp.pop_back();
                }
                ans.insert(ans.begin(), tmp.back());
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1), tmp;
        vector<int> ans;
        int ct=0;
        bool isc=false;
        dfs(1, tmp, v, edges, ans, ct, k, isc);
        if(isc)
        {
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
            return 0;
        }
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs1(int idx, vector<int> &vis, vector<vector<ll>> &edges, int ct, int k, bool &isc, int &start)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs1(y, vis, edges, ct+1, k, isc, start);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                start = y;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int gt;
vector<bool> h(100001,0);
void dfs(int idx, vector<int> &par, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    //tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        int nn=edges.size();
        if(vis[y]==-1){
            par[y] = idx;
            dfs(y, par, vis, edges, ans, ct+1, k, isc);
        }
        else if(par[y] == nn)
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                int tmp = idx,ct=0;
                while(tmp!=nn && !h[tmp])
                {
                    //if(gt==100000 && ct>99995){
                    //    h[tmp]=1;
                    //    cout<<tmp<<" "<<y<<" "<<nn<<"    ";
                    //}
                    //ans.insert(ans.begin(), tmp);
                    ans.push_back(tmp);
                    tmp = par[tmp];
                    //ct++;
                }
                //if(gt==100000)
                //    cout<<tmp<<" "<<h[tmp]<<" "<<y<<" "<<nn<<endl;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
    ios::sync_with_stdio(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
	    gt=k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        int start;
        dfs1(1, v, edges, ct, k, isc, start);
        if(isc)
        {
            ct=0;
            isc=false;
            vector<int> ans;
            vector<int> par(n+1,-1);
            vector<int> v(n+1,-1);
            par[start]= n+1;
            dfs(start, par, v, edges, ans, ct, k, isc);
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[len-1-i]<<" ";
            cout<<endl;
            return 0;
        }
        if(1){
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
        }
	}
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

void dfs1(int idx, vector<int> &vis, vector<vector<ll>> &edges, int ct, int k, bool &isc, int &start)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        if(vis[y]==-1)
            dfs1(y, vis, edges, ct+1, k, isc, start);
        else
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                start = y;
                isc=1;
            }
        }
        if(isc)
            return;
    }
}

void dfs(int idx, vector<int> &par, vector<int> &vis, vector<vector<ll>> &edges, vector<int> &ans, int ct, int k, bool &isc)
{
    if(isc)
        return;
    vis[idx] = ct;
    int i,n=edges[idx].size();
    //tmp.push_back(idx);
    for(i=0;i<n;i++)
    {
        int y = edges[idx][i];
        int nn=edges.size();
        if(vis[y]==-1){
            par[y] = idx;
            dfs(y, par, vis, edges, ans, ct+1, k, isc);
        }
        else if(par[y] == nn)
        {
            int len = abs(ct-vis[y])+1;
            if(len>=3 && len <=k){
                //cout<<y<<" "<<idx<<" "<<ct<<" "<<vis[y]<<endl;
                //while(tmp.back() != y)
                //{
                //    ans.insert(ans.begin(), tmp.back());
                //    tmp.pop_back();
                //}
                //ans.insert(ans.begin(), tmp.back());
                //ans.insert(ans.begin(), y);
                int tmp = idx;
                while(tmp!=nn)
                {
                    //cout<<tmp<<endl;
                    ans.insert(ans.begin(), tmp);
                    tmp = par[tmp];
                }

                isc=1;
            }
        }
        if(isc)
            return;
    }
}

int main() {
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    ll i,j,n,m,k;
	    cin>>n>>m>>k;
        vector<vector<ll>> edges(n+1);
        for(i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            edges[x].push_back(y);
            edges[y].push_back(x);
        }
        vector<int> v(n+1,-1);
        int ct=0;
        bool isc=false;
        int start;
        dfs1(1, v, edges, ct, k, isc, start);
        if(isc)
        {
            ct=0;
            isc=false;
            vector<int> ans;
            vector<int> par(n+1,-1);
            vector<int> v(n+1,-1);
            par[start]= n+1;
            dfs(start, par, v, edges, ans, ct, k, isc);
            cout<<2<<endl;
            ll len = ans.size();
            cout<<len<<endl;
            for(i=0;i<len;i++)
                cout<<ans[i]<<" ";
            cout<<endl;
            return 0;
        }
        if(k!=10000){
        vector<int> level(n+1,-1);
        level[1]= 0;
        queue<pair<int,int>> q;
        q.push(make_pair(1,0));
        while(!q.empty())
        {
            pair<int,int> p = q.front();
            q.pop();

            int i,l = edges[p.first].size();
            for(i=0;i<l;i++)
            {
                int y = edges[p.first][i];
                if(level[y]==-1)
                {
                    level[y] = p.second+1;
                    q.push(make_pair(y, level[y]));
                }
            }
        }
        vector<int> even, odd;
        cout<<1<<endl;
        for(i=1;i<=n;i++)
        {
            if(level[i]%2)
                odd.push_back(i);
            else
                even.push_back(i);
        }
        int num = k/2 + (k%2);
        if(even.size() >= num)
            for(i=0;i<num;i++)
                cout<<even[i]<<" ";
        else
            for(i=0;i<num;i++)
                cout<<odd[i]<<" ";
        cout<<endl;
        }
	}
}