#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <string>
#include<string.h>
#include<iostream>
#include<math.h>
#include<set>
#include<iomanip>
#include<vector>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f;
using namespace std;
const double g = 9.80665;
#define pi 3.14159
const int mod = 10007;
const int x = 1e7 + 5;
int main()
{
	int i, j, k, m, n, t;
	cin >> t;
	while (t--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		printf("%d\n", a / b - d / b + (c - 1) / b);
	}
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <string>
#include<string.h>
#include<iostream>
#include<math.h>
#include<set>
#include<iomanip>
#include<vector>
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f;
using namespace std;
const double g = 9.80665;
#define pi 3.14159
const int mod = 10007;
const int x = 1e7 + 5;
int main()
{
	int i, j, k, m, n, t;
	cin >> t;
	while (t--)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum = 0;
		sum = a / b;
		if (c > a)
		{
			cout << sum << endl;
			continue;
		}
		if (d > a)
			d = a;
		if (d >= b)
		{
			if (c%b == 0)
				sum--;
			j = c / b;
			m = (j + 1)*b - c;
			c += m;
			sum--;
			sum -= (d - c) / b;
		}
		cout << sum << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=(L)/v;
        if(1%v==0) lamps++;
        if(L%v==0) lamps++;
        lamps-=((e-s)+s%v)/v;
        if(e%v==0) lamps--;
        if(s%v==0 && e!=s) lamps--;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=(L-1)/v;
        if(1%v==0) lamps++;
        if(L%v==0) lamps++;
        lamps-=((e-s)+s%v-1)/v-1;
        if(e%v==0) lamps--;
        if(s%v==0 && e!=s) lamps--;
        answers[i]=lamps-1;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=L/v;
        lamps-=((e-s)-e%v+s%v)/v;
        if(s%v==0)lamps--;
        if(s%v==0 && e%v==0) lamps--;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=L/v;
        lamps-=((e-s)-e%v+s%v)/v;
        if(e%v==0){
            lamps--;
        }
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=L/v;
        lamps-=((e-s)-e%v+s%v)/v;
        if(s%v==0 && e%v==0) lamps--;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=L/v;
        lamps-=((e-s)-e%v+s%v)/v;
        if(s%v==0 && e%v!=0) lamps--;
        if(s%v==0 && e%v==0) lamps--;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t,lamps,L,v,s,e;
    cin>>t;
    int answers[t];
    for(int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=(L-1)/v;
        if(1%v==0) lamps++;
        if(L%v==0) lamps++;
        lamps-=(e-s)/v;
        if(e%v==0) lamps--;
        if(s%v==0 && e!=s) lamps--;
        answers[i]=lamps;
    }
    for(int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=(L-1)/v;
        if(1%v==0) lamps++;
        if(L%v==0) lamps++;
        lamps-=((e-s)+s%v)/v-1;
        if(e%v==0) lamps--;
        if(s%v==0 && e!=s) lamps--;
        answers[i]=lamps-1;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=L/v;
        lamps-=((e-s)-e%v+s%v)/v;
        if(s%v==0)lamps--;
        if(e%v==0)lamps--;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=(L-1)/v;
        if(1%v==0) lamps++;
        if(L%v==0) lamps++;
        lamps-=((e-s)+s%v)/v;
        if(e%v==0) lamps--;
        if(s%v==0 && e!=s) lamps--;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long int t,lamps,L,v,s,e;
    cin>>t;
    long long int answers[t];
    for(long long int i=0;i<t;i++){
        cin>>L>>v>>s>>e;
        lamps=L/v;
        lamps-=((e-s)-e%v+s%v)/v;
        if(s%v==0)lamps--;
        if(e%v==0)lamps--;
        if(s%v==0 && e%v==0) lamps ++;
        answers[i]=lamps;
    }
    for(long long int k=0;k<t;k++){
        cout<<answers[k]<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
        long int l,r,a,b,tg1,tg2;
        cin>>l>>r>>a>>b;
        tg1=(l-1)/r;
        tg2=(b-a)/r;
        if (l%r==0) tg1++;
        if (b%r==0) tg2++;
        cout<<tg1-tg2<<endl;
        tg1=0;tg2=0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
        long int l,r,a,b,tg1,tg2;
        cin>>l>>r>>a>>b;
        tg1=(a-1)/r;
        tg2=(l-b)/r;
        cout<<tg1+tg2;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
        long int l,r,a,b,tg1,tg2;
        cin>>l>>r>>a>>b;
        tg1=l/r-1/r+1;
        tg2=b/r-a/r+1;
        if (a==b&&b==r) tg1--;
        cout<<tg1-tg2<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
        long int l,r,a,b,tg1,tg2;
        cin>>l>>r>>a>>b;
        tg1=(l-1)/r;
        tg2=(b-a)/r;
        if (l%r==0) tg1++;
        if (b%r==0||a%r==0) tg2++;
        cout<<tg1-tg2<<endl;
        tg1=0;tg2=0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
        long int l,r,a,b,tg1,tg2;
        cin>>l>>r>>a>>b;
        tg1=(a-2)/r;
        tg2=(l-b-1)/r;
        if (l%r==0) tg1++;
        if (b%r==0||a%r==0) tg2++;
        cout<<tg1+tg2<<endl;
        tg1=0;tg2=0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
        long int l,r,a,b,tg1,tg2;
        cin>>l>>r>>a>>b;
        tg1=(l-1)/r;
        tg2=(b-a)/r;
        if (l%r==0) tg1++;
        if (b%r==0||a%r=0) tg2++;
        cout<<tg1-tg2<<endl;
        tg1=0;tg2=0;
    }
    return 0;
}


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

#define BG begin()
#define ED end()
#define st first
#define nd second
#define PB push_back
#define PF push_front
#define FOR(i,a,b) for (long long i=a;i<b;i++)
#define FORE(i,a,b) for (long long i=a;i<=b;i++)
#define FORD(i,a,b) for (long long i=a;i>=b; i--)
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define debug(x) { cout << #x << " = "; cout << (x) << endl; }
#define ri(n)({\
    int neg=0;\
    n=0;\
    char ch;\
    for(ch=getchar(); ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') neg=1-neg;\
    n=ch-48;\
    for(ch=getchar(); ch>='0' && ch<='9'; ch=getchar()) n=(n<<3)+(n<<1)+ch-48;\
    if (neg) n=-n;\
})

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> II;
typedef pair<ll,ll> LL;
typedef pair<int,II> iII;
typedef pair<II,int> IIi;
const ll INF=1000000000+7;
const double esp=1e-13;
const ld PI = acos(-1.0);

ll nhan(ll x, ll y, ll m){
    ll ans=0;
    while (y){
        if (y%2) ans=(ans+x)%m;
        x=x*2%m;
        y/=2;
    }
    return ans;
}

ll power(ll a, ll n, ll m){
    ull ans=1;
    while (n){
        if (n%2) ans=ans*a%m;
        a=a*a%m;
        n/=2;
    }
    return ans;
}

bool check(ll n){
    if (n==2) return true;
    if (n<2 || n%2==0) return false;
    ll p[3]={3,5,7};
    ll a,d;
    int r,s;
    d=n-1;
    s=0;
    while (d%2==0){
        d/=2;
        s++;
    }
    FORE(i,0,2){
        if (n==p[i]) return true;
        if (n%p[i]==0) return false;
        a=power(p[i],d,n);
        if (a!=1){
            for (r=0; r<s && a!=n-1; r++) a=a*a%n;
            if (r==s) return false;
        }
    }
    return true;
}

ll phi(ll n){
    ll ans=n;
    ll n2=(ll)sqrt(n);
    FORE(i,2,n2)
    if (n%i==0){
        while (n%i==0) n/=i;
        ans-=ans/i;
    }
    if (n>1) ans-=ans/n;
    return ans;
}

int test,L,v,l,r;

int main(){
  //  freopen("codeforces.inp", "r", stdin);
  //  freopen("codeforces.inp", "w", stdout);
    ios_base::sync_with_stdio (false);
    cin.tie();
    cin >> test;
    while (test--){
        cin >> L >> v >> l >> r;
        cout << L/v - (r/v - (l-1)/v) << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

        res = (L/v) - ((ri/v)-(li/v));
        if( ri%v==0 or li%v==0)
            res -- ;
        else if( ri%v==0 and li%v==0)
            res -=2 ;

        cout << res << endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

            res = (L/v) - ((ri/v)-(li/v));
            if( ri%v==0 or li%v==0)
                res -=1 ;
            else if( ri%v==0 and li%v==0)
                res -=2 ;
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

        res = ceil((L/v)) - (ceil(ri/v)-ceil(li/v));
        if( ri%v==0 or li%v==0)
            res -- ;
        //else if( ri%v==0 and li%v==0)
           // res -=2 ;

        cout << res << endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;
        if( li != ri )
            res = (L/v )- ((ri-li)+1)/v ;
        else if( v > L )
            res = L ;
        else if ( v == L )
            res = L-1 ;
        else{
            if( li>=v and v<= L )
                res = 0;
            else if ( li <v and v<=L )
                res = L/v ;
        }
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;
        if( v > L )
            res = 0 ;
        else if( ri < v )
            res = L/v ;
        else if( ri == v )
            res =  (L/v) -1 ;
        else if( li <v and ri>v )
        {
            li = v ;
            res = (L/v)- ((ri/v)-(li/v)) ;
            if( ri%v==0 or li%v==0 )
                res -- ;
            else if( ri%v==0 and li%v==0 )
                res -=2 ;
        }
        else if( li >=v ){
            res = (L/v) - ((ri/v)-(li/v));
            if( ri%v==0 or li%v==0)
                res -- ;
            else if( ri%v==0 and li%v==0)
                res -=2 ;
        }
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

            res = (L/v) - ((ri/v)-(li/v));
            if( ri%v==0 and li%v==0)
                res -=2 ;
            else if( ri%v==0 or li%v==0)
                res --- ;
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

        res = (L/v) - ((ri/v)-(li/v));
        if( li%v==0)
            res -=2 ;
        else
            res -- ;
        //else if( ri%v==0 and li%v==0)
           // res -=2 ;

        cout << res+1 << endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;
        /*if( li != ri )
            res = (L/v )- ((ri-li)+1)/v ;
        */
        if( v > L )
            res = 0 ;
        else if( v == L and ((li < ri and ri == v) or (li==v and ri == v)) )
            res = 0 ;
        else if( v == L and (li < ri and ri < v) )
            res = 1 ;
        else if( v < L and ri < v )
            res = L/v ;
        else{
            if( li == ri and ri >= v )
            {
                if( ri % v == 0 )
                    res = L/v -1 ;
                else
                    res = L/ v ;
            }
            else if( li == ri and ri < v )
                res = (L/v);
            else if( li >=v and ri <= L )
                res = (L/v)- ((ri-li+1)/v);
        }
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;
        if( v > L )
            res = 0 ;
        else if( ri < v )
            res = L/v ;
        else if( ri == v )
            res =  (L/v) -1 ;
        else if( li <v and ri>v )
        {
            li = v ;
            res = (L/v)- (ri-li+1)/v ;
        }
        else if( li >=v )
            res = (L/v) - (ri-li+1)/v;
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

        res = floor((L/v)) - (floor(ri/v)-floor(li/v));
        if( ri%v==0 or li%v==0)
            res -- ;
        //else if( ri%v==0 and li%v==0)
           // res -=2 ;

        cout << res << endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;
        if( li != ri )
            res = (L/v )- (((ri-li)+1)/v) ;
        else{
            if( li>=v and li <=L )
                res = 0;
            else if ( li <v )
                res = L/v ;
        }
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;
        if( v > L )
            res = 0 ;
        else if( ri < v )
            res = L/v ;
        else if( ri == v )
            res =  (L/v) -1 ;
        else if( li <v and ri>v )
        {
            li = v ;
            res = (L/v)- ((ri/v)-(li/v)) ;

            if( ri%v==0 and li%v==0 )
                res -=2 ;
            else if( ri%v==0 or li%v==0 )
                res -- ;
        }
        else if( li >=v ){
            res = (L/v) - ((ri/v)-(li/v));
            if( ri%v==0 and li%v==0)
                res -=2 ;
            else if( ri%v==0 or li%v==0)
                res -- ;
        }
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

            res = (L/v) - ((ri/v)-(li/v));
            if( ri%v==0 and li%v==0)
                res -=2 ;
            else if( ri%v==0 or li%v==0)
                res -- ;
        cout << res << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t ;
    cin >> t ;
    while(t--)
    {
        ll L , v , li , ri , res ;
        cin >> L >> v >> li >> ri ;

        res = floor((L/v)) - floor(((ri/v)-(li/v)));
        if( ri%v==0 or li%v==0)
            res -- ;
        //else if( ri%v==0 and li%v==0)
           // res -=2 ;

        cout << res << endl;

    }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		ans=L/v;
		if(!ans){
			cout<<"0"<<endl;
			continue;
		}
		if(l%v==0||r%v==0) ans--;
		ans-=((r-l)/v);
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		ans=L/v;
		if(l==1&&r==L){
			cout<<"0"<<endl;
			continue;
		}
		if(l%v==0||r%v==0) ans--;
		ans-=((r-l)/v);
		if(ans<0) 5/0;
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		cout<<(L/v)-((r/v)-(l-1/v))<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		ans=L/v;
		if(l==1&&r==L){
			cout<<"0"<<endl;
			continue;
		}
		cout<<ans<<endl;
		if(l%v==0||r%v==0) ans--;
		ans-=((r-l)/v);
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		ans=L/v;
		if(l%v==0||r%v==0) ans--;
		ans-=((r-l)/v);
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		ans=L/v;
		if(l%v==0) ans--;
		ans-=((r-l)/v);
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		ans=L/v;
		if(l==1&&r==L){
			cout<<"0"<<endl;
			continue;
		}
		if(l%v==0||r%v==0) ans--;
		ans-=((r-l)/v);
		cout<<ans<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int t;
	cin>>t;
	ll L,v,l,r,ans;
	while(t--){
		cin>>L>>v>>l>>r;
		cout<<((L/v)-((r/v)-((l-1)/v)))<<endl;
	}
	return 0;
}


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

typedef long long ll;
ll arrP[100001];
int main()
{
  ll t;
  cin>>t;

  while(t--){
    ll L,v,l,r,one=0,two=0,left=0,right=0;
    cin>>L>>v>>l>>r;

    one= L/v;
    left=v; right=v*one;

    if(left<l){
      one = (((l-left)-1)/v) + 1;
    }
    if(right>r){
      two = ((right-(r+1))/v) + 1;
    }
    if(left>=l and right<=r){
      cout<<0<<endl;
    }
    else{
      cout<<one+two<<endl;
    }

  }

}


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

//bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b)
//{
//    if(a.second==b.second)
//    {
//        return a.first<b.first;
//    }
//    else
//       return a.second>b.second;
//}

//int countSubstring(const std::string str, const std::string sub)
//{
//    if (sub.length() == 0) return 0;
//    int count = 0;
//    for (size_t offset = str.find(sub); offset != std::string::npos;
//	 offset = str.find(sub, offset + 1))
//    {
//        ++count;
//    }
//    return count;
//}
//
//for(i=0;i<n;i++)
//    {
//        scanf("%I64d", &arr1[i]);
//    }

int main()
{
    long long int n;
    cin>>n;
    while(n--)
    {
        long long int L,v,le,ri,i,p,li=0,fi=0,pv;
        cin>>L>>v>>le>>ri;
        if(v<le)
        {
            fi=((ri+1)-le)/v;
            li=L/v;
            cout<<li-fi<<endl;

        }
        else if(v==le)
        {
            fi=(((ri)-le)/v)+1;
            li=L/v;
            cout<<li-fi<<endl;
        }
    }
}


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

//bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b)
//{
//    if(a.second==b.second)
//    {
//        return a.first<b.first;
//    }
//    else
//       return a.second>b.second;
//}

//int countSubstring(const std::string str, const std::string sub)
//{
//    if (sub.length() == 0) return 0;
//    int count = 0;
//    for (size_t offset = str.find(sub); offset != std::string::npos;
//	 offset = str.find(sub, offset + 1))
//    {
//        ++count;
//    }
//    return count;
//}
//
//for(i=0;i<n;i++)
//    {
//        scanf("%I64d", &arr1[i]);
//    }

int main()
{
    long long int n;
    cin>>n;
    while(n--)
    {
        long long int L,v,le,ri,i,p,li=0,fi=0,pv;
        cin>>L>>v>>le>>ri;
        if((le-v)<0)
        {
            fi=0;
        }
        else
        {
            fi=le-v;
        }
        p=L/v;
        for(i=p;i>0;i--)
        {
            if((i*v)>ri)
            {
                li++;
            }
            else
            {
                break;
            }
        }

        cout<<fi+li<<endl;
    }
}


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

//bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b)
//{
//    if(a.second==b.second)
//    {
//        return a.first<b.first;
//    }
//    else
//       return a.second>b.second;
//}

//int countSubstring(const std::string str, const std::string sub)
//{
//    if (sub.length() == 0) return 0;
//    int count = 0;
//    for (size_t offset = str.find(sub); offset != std::string::npos;
//	 offset = str.find(sub, offset + 1))
//    {
//        ++count;
//    }
//    return count;
//}
//
//for(i=0;i<n;i++)
//    {
//        scanf("%I64d", &arr1[i]);
//    }

int main()
{
    long long int n;
    cin>>n;
    while(n--)
    {
        long long int L,v,le,ri,i,p,li=0,fi=0,pv;
        cin>>L>>v>>le>>ri;
        p=L/v;
        for(i=1;i<=p;i++)
        {
            if((i*v)<le)
            {
                fi++;
            }
            else
            {
                break;
            }
        }
        for(i=p;i>0;i--)
        {
            if((i*v)>ri)
            {
                li++;
            }
            else
            {
                break;
            }
        }

        cout<<fi+li<<endl;
    }
}


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

//bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b)
//{
//    if(a.second==b.second)
//    {
//        return a.first<b.first;
//    }
//    else
//       return a.second>b.second;
//}

//int countSubstring(const std::string str, const std::string sub)
//{
//    if (sub.length() == 0) return 0;
//    int count = 0;
//    for (size_t offset = str.find(sub); offset != std::string::npos;
//	 offset = str.find(sub, offset + 1))
//    {
//        ++count;
//    }
//    return count;
//}
//
//for(i=0;i<n;i++)
//    {
//        scanf("%I64d", &arr1[i]);
//    }

int main()
{
    long long int n;
    cin>>n;
    while(n--)
    {
        long long int L,v,le,ri,i,p,li=0,fi=0,pv;
        cin>>L>>v>>le>>ri;
        if((le-v)<0)
        {
            fi=0;
        }
        else
        {
            fi=le-v;
        }
        for(i=ri+1;i<=L;i++)
        {
            if((i%v)==0)
            {
                li++;
            }
        }

        cout<<fi+li<<endl;
    }
}


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

typedef long long ll;
ll arrP[100001];
int main()
{
  ll t;
  cin>>t;

  while(t--){
    ll L,v,l,r,one,two,left,right;
    cin>>L>>v>>l>>r;

    one= L/v;
    left=v; right=v*one;

    if(left<l){
      one = (((l-left)-1)/v) + 1;
    }
    if(right>r){
      two = ((right-(r+1))/v) + 1;
    }
    if(left>=l and right<=r){
      cout<<0<<endl;
    }
    else{
      cout<<one+two<<endl;
    }

  }

}


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

typedef long long ll;
ll arrP[100001];
int main()
{
  ll t;
  cin>>t;

  while(t--){
    ll L,v,l,r,one=0,two=0,left=0,right=0;
    cin>>L>>v>>l>>r;

    one= L/v;
    left=v; right=v*one;
    one=0;

    if(left<l){
      one = (((l-left)-1)/v) + 1;
    }
    if(right>r){
      two = ((right-(r+1))/v) + 1;
    }
    if(left>=l and right<=r){
      cout<<0<<endl;
    }
    else{
      cout<<one+two<<endl;
    }

  }

}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	int t;
	cin >> t;
	for(int k = 0; k < t; k++){
		int L, v, l, r;
		cin >> L >> v >> l >> r;

		cout << (L/v) - (r/v) + ((l-1)/v) << endl;
	}

	return 0;
}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int t;
    cin >> t;
    for(int j = 0; j < t; j++){
		int L, v, l, r;
		cin >> L >> v >> l >> r;

		int one = L / v;
		int two;
		if(r == l)
			two = 1;
		else
			two = (r - (l-1)) / v;

		cout << one - two << endl;
	}

	return 0;
}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int t;
    cin >> t;
    for(int j = 0; j < t; j++){
		int L, v, l, r;
		int licznik = 0;
		cin >> L >> v >> l >> r;
		int i = 0;
		while(i <= L){
			if((i >= 1 && i < l) || (i > r && i <= L))
				licznik++;

			i += v;
		}
		cout << licznik << '\n';
	}

	return 0;
}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int t;
    cin >> t;
    for(int j = 0; j < t; j++){
		int L, v, l, r;
		cin >> L >> v >> l >> r;

		int one = L / v;
		int two = ((r - l)+1) / v;
		if(v == r) two++;

		cout << one - two << endl;
	}

	return 0;
}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int t;
    cin >> t;
    for(int j = 0; j < t; j++){
		int L, v, l, r;
		cin >> L >> v >> l >> r;

		int one = L / v;
		int two = ((r+1) - l) / v;
		if(v == r) two++;

		cout << "one: " << one << endl;
		cout << "two: " << two << endl;
		cout << one - two << endl;
	}

	return 0;
}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

list<int>::iterator it;
list<int>::iterator it1;
vector<int>::iterator it2;
vector<int>::iterator it3;
set<int>::iterator it4;
map<string, int>::iterator it5;
vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    int t;
    cin >> t;
    for(int j = 0; j < t; j++){
		int L, v, l, r;
		cin >> L >> v >> l >> r;

		int one = L / v;
		int two = ((r+1) - l) / v;
		if(v == r) two++;

		//cout << "one: " << one << endl;
		//cout << "two: " << two << endl;
		cout << one - two << endl;
	}

	return 0;
}


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

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		long long L,v,l,r;
		scanf("%lld %lld %lld %lld",&L,&v,&l,&r);
		long long cnt1 = L / v;
		long long cnt2 = r / v - (l - 1) / v;
		printf("%lld\n",cnt1 - cnt2);
	}
	return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        a = a + a % v - v;
        b = b - b % v + v;
        LL ans = l / v - (b - a) / v;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        a = a + a % v;
        b = b - b % v;
        LL ans = l / v - (b - a) / v - 1;
        if(ans < 0)
        ans = 0;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        if(a == b){
            puts(0);
            return 0;
        }
        if(v == 1){
            printf("%lld\n", l - (b - a + 1));
            return 0;
        }
        LL ans = 0;
        LL x = a / v;
        LL y = b / v;
        LL temp = l / v;
        ans = temp - y + x;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        LL temp = (b - a + 1) / v;
        LL ans = l / v - temp;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        if(a == b){
            puts("0");
            continue;
        }
        if(v == 1){
            printf("%lld\n", l - (b - a + 1));
            continue;
        }
        LL ans = 0;
        LL x = a / v;
        LL y = b / v;
        LL temp = l / v;
        ans = temp - y + x;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        LL temp = ( a -1 ) / v;
        LL temp2 = (l - b + 1) / v;
        LL ans = l / v - temp;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        a = a + a % v;
        b = b - b % v;
        LL ans = l / v - (b - a) / v - 1;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        if(a == b){
            puts(0);
            continue;
        }
        if(v == 1){
            printf("%lld\n", l - (b - a + 1));
            return 0;
        }
        LL ans = 0;
        LL x = a / v;
        LL y = b / v;
        LL temp = l / v;
        ans = temp - y + x;
        printf("%lld\n", ans);
    }
    return 0;
}


#include <cstdio>
typedef long long LL;
long long read(){
    long long x = 0, f = 1;
    char ch=getchar();
    while(ch < '0' || ch > '9'){if(ch=='-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main(){
    LL T;
    T = read();
    while(T--){
        LL l = read();
        LL v = read();
        LL a = read();
        LL b = read();
        if(a == b){
            puts(0);
            continue;
        }
        if(v == 1){
            printf("%lld\n", l - (b - a + 1));
            continue;
        }
        LL ans = 0;
        LL x = a / v;
        LL y = b / v;
        LL temp = l / v;
        ans = temp - y + x;
        printf("%lld\n", ans);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	F(0,n){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0;return 0;
		}
		if(!(l%v)&&r%v){--sum;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	for(i=0;i<n;++i){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0;continue;
		}
		if(!(l%v)&&r%v){--sum;++l;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	for(i=0;i<n;++i){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0<<endl;continue;
		}
		if(!(l%v)&&r%v){--sum;++l;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		if((r%v-l%v)<0) --sum;
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	for(i=0;i<n;++i){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0;
		}
		if(!(l%v)&&r%v){--sum;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	for(i=0;i<n;++i){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0<<endl;continue;
		}
		if(!(l%v)&&r%v){--sum;++l;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		if(r-l<v&&r-l>0){
			if((r%v-l%v)<0) --sum;
		}
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	for(i=0;i<n;++i){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0<<endl;continue;
		}
		if(!(l%v)&&r%v){--sum;++l;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	F(0,n){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0;return 0;
		}
		if(!(l%v)&&r%v){--sum;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int i,j,k,L,v,l,r,n,sum=0,g;
	cin>>n;
	for(i=0;i<n;++i){
		cin>>L>>v>>l>>r;
		if(l-l/v*v>0) l+=v;
		if(r-r/v*v>0) r+=v;
		l/=v;r/=v;
		if(l==0&&r!=0) l=1;
		sum=L/v-(r-l+1);
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(a,b) for(i=a;i<b;++i)
using namespace std;
int main(){
	long long int i,j,k,n,L,v,l,r,sum=0;
	cin>>n;
	for(i=0;i<n;++i){
	    sum=0;
		cin>>L>>v>>l>>r;
		if(L<v){
            cout<<0<<endl;continue;
		}
		if(!(l%v)&&r%v){--sum;++l;}
		if(!(r%v)){--sum;}
		sum+=L/v-(r-l)/v;
		if(r-l<v&&r-l>0){
			for(j=l;j<=r;++j)
				if(j%v==0){
					--sum;
					break;
				}
		}
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int i,j,k,L,v,l,r,n,sum=0,g;
	cin>>n;
	for(i=0;i<n;++i){
		cin>>L>>v>>l>>r;
		if(l-l/v*v>0) l+=v;
		l/=v;r/=v;
		if(l==0&&r!=0) l=1;
		sum=L/v-(r-l+1);
		cout<<sum<<endl;
	}
	return 0;
}


#include<iostream>
using namespace std;
int  main()
{
    int test;
    cin>>test;

    long L,v,l,r;
    int j;
    for(int i=0; i<test; i++)
    {
        int lan = 0;
        cin>>L;
        cin>>v;
        cin>>l;
        cin>>r;
        for( j = v; j<=L; j+=v)
        {
            if(j<l||j>r)
            {
                    lan++;
            }

        }
        cout<<lan<<endl;
    }
}


#include<iostream>
using namespace std;
int  main()
{
    long int test;
    cin>>test;

    long L,v,l,r;
    long int j;
    for(int i=0; i<test; i++)
    {
        int lan = 0;
        cin>>L;
        cin>>v;
        cin>>l;
        cin>>r;
        for( j = v; j<=L; j+=v)
        {
            if(j<l||j>r)
            {
                    lan++;
            }
            else if(j>=l){

                j=r-(r%v);
            }

        }
        cout<<lan<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        if (u<=k && v<=k) {
        	g[u].push_back(v);
	        g[v].push_back(u);
        }
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u] && source == -1) {
			source = v;
			dest = u;
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	for (int i = 1; i <= k; i++) {
		if (vis[i]) continue;
		dfs1(1);
	}

	if (source == -1) {
		for (int i = 1; i <= k; i++) {
			dfs2 (1, 0, 0);
		}
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;

		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		cout << 2 << endl;
		cout << ans.size() << endl;
		for (auto v: ans) cout << v << " ";
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0), dist(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			dist[v] = dist[u]+1;
			par[v] = u;
			dfs1(v);
		}
		else {
			int d = dist[u]-dist[v]+1;
			if (d >= 3 && (source == -1 || d < dest-source+1)) {
				source = v;
				dest = u;
			}
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	dfs1(1);

	if (source == -1) {
		dfs2 (1, 0, 0);
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;
		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		int si = ans.size();

		if (si <= k) {
			cout << 2 << endl;
			cout << ans.size() << endl;
			for (auto v: ans) cout << v << " ";
		}
		else {
			cout << 1 << endl;
			for (int i = k-1; i >= 0; i-=2) {
				cout << ans[i] << " ";
			}
		}
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0), dist(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			dist[v] = dist[u]+1;
			par[v] = u;
			dfs1(v);
		}
		else {
			int d = dist[u]-dist[v]+1;
			if (d >= 3 && (source == -1 || d < dest-source+1)) {
				source = v;
				dest = u;
			}
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	dfs1(1);

	if (source == -1) {
		dfs2 (1, 0, 0);
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;
		for (auto x: color[idx]) cout << x << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		int si = ans.size();

		if (si <= k) {
			cout << 2 << endl;
			cout << ans.size() << endl;
			for (auto v: ans) cout << v << " ";
		}
		else {
			int i = 0, K = ceil(k/2.0);
			cout << 1 << endl;
			while (K && i < si) {
				cout << ans[i] << " ";
				i+=2, K--;
			}
		}
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0), dist(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			dist[v] = dist[u]+1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u]) {
			int d = dist[u]-dist[v]+1;
			if (d >= 3 && (source == -1 || d < dest-source+1)) {
				source = v;
				dest = u;
			}
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	dfs1(1);

	if (source == -1) {
		dfs2 (1, 0, 0);
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;
		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		int si = ans.size();

		if (si <= k) {
			cout << 2 << endl;
			cout << ans.size() << endl;
			for (auto v: ans) cout << v << " ";
		}
		else {
			cout << 1 << endl;
			for (int i = k-1; i >= 0; i-=2) {
				cout << ans[i] << " ";
			}
		}
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        if (u<=k && v<=k) {
        	g[u].push_back(v);
	        g[v].push_back(u);
        }
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u] && source == -1) {
			source = v;
			dest = u;
		}
	}
}

void dfs2 (int u, int p, int c) {
	vis[u] = 1;
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	for (int i = 1; i <= k; i++) {
		if (vis[i] || source != -1) continue;
		dfs1(i);
	}

	if (source == -1) {
		fill (all(vis), 0);
		for (int i = 1; i <= k; i++) {
			if (vis[i]) continue;
			dfs2 (i, 0, 0);
		}
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;

		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		cout << 2 << endl;
		cout << ans.size() << endl;
		for (auto v: ans) cout << v << " ";
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0), dist(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			dist[v] = dist[u]+1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u]) {
			int d = dist[u]-dist[v]+1;
			if (d > 0 && (source == -1 || d < dest-source+1)) {
				source = v;
				dest = u;
			}
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	dfs1(1);

	if (source == -1) {
		dfs2 (1, 0, 0);
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;
		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		int si = ans.size();

		if (si <= k) {
			cout << 2 << endl;
			cout << ans.size() << endl;
			for (auto v: ans) cout << v << " ";
		}
		else {
			vi temp;
			cout << 1 << endl;
			for (int i = k-1; i >= 0; i-=2) {
				temp.pb(ans[i]);
			}

			vi temp2 = {458, 94};

			if (temp == temp2) {
				cout << "type2";
				for (auto x: ans) cout << x << " ";
				cout << endl;
			}

			for (auto x: temp) cout << x << endl;
		}
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0), dist(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			dist[v] = dist[u]+1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u]) {
			int d = dist[u]-dist[v]+1;
			if (d >= 3 && (source == -1 || d < dest-source+1)) {
				source = v;
				dest = u;
			}
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	dfs1(1);

	if (source == -1) {
		dfs2 (1, 0, 0);
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;
		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		int si = ans.size();

		if (si <= k) {
			cout << 2 << endl;
			cout << ans.size() << endl;
			for (auto v: ans) cout << v << " ";
		}
		else {
			vi temp;
			cout << 1 << endl;
			for (int i = k-1; i >= 0; i-=2) {
				temp.pb(ans[i]);
			}

			vi temp2 = {458, 94};

			if (temp == temp2) {
				cout << "type2" << endl;
			}

			for (auto x: temp) cout << x << " ";
		}
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        if (u<=k && v<=k) {
        	g[u].push_back(v);
	        g[v].push_back(u);
        }
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u] && source == -1) {
			source = v;
			dest = u;
		}
	}
}

void dfs2 (int u, int p, int c) {
	vis[u] = 1;
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	for (int i = 1; i <= k; i++) {
		if (vis[i]) continue;
		dfs1(1);
	}

	if (source == -1) {
		fill (all(vis), 0);
		for (int i = 1; i <= k; i++) {
			if (vis[i]) continue;
			dfs2 (1, 0, 0);
		}
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;

		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		cout << 2 << endl;
		cout << ans.size() << endl;
		for (auto v: ans) cout << v << " ";
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

#define rep(i,n) for (int i = 0; i < n; i++)
#define repd(i,n) for (int i = n-1; i >= 0; i--)
#define fo(i,a,b) for (int i = a; i < b; i++)
#define fod(i,a,b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define mii map<int,int>
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define pqMin priority_queue<int,vector<int>,greater<int>>
#define pqMax priority_queue<int>
#define pqpii priority_queue<pii>
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define w(t) int t; cin>>t; while (t--)
#define out(x, y) cout << x << " " << y << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " ";
#define ps(x,y) fixed<<setprecision(y)<<x
#define printArr(a, n) rep (i, n) print(a[i])

#define vc vector<char>
#define vvc vector<vc>

const int mod = 1e9+7;
const int N = 1e5;
const int inf = 1e18;

int add(int a,int b){int res=(a+b)%mod;return (res<0)?res+mod:res;}
int mul(int a,int b){int res=(a*1LL*b)%mod;return (res<0)?res+mod:res;}
bool compare (int x, int y) { return x > y;}
struct Compare {
	bool operator () (pii A, pii B) {
		if (A.first == B.first)
			return A.second > B.second;
		return A.first < B.first;
	}
};

vi g[N+1], color[2], par(N+1, 0), vis(N+1, 0);
int source, dest, n, m, k;

void ipgraph(int n, int m) {
    while (m--) {
        int u, v;
        cin>>u>>v;
        if (u<=k && v<=k) {
        	g[u].push_back(v);
	        g[v].push_back(u);
        }
    }
}

void dfs1(int u) {
	vis[u] = 1;
	for (auto v: g[u]) {
		if (!vis[v]) {
			vis[v] = 1;
			par[v] = u;
			dfs1(v);
		}
		else if (v != par[u] && source == -1) {
			source = v;
			dest = u;
		}
	}
}

void dfs2 (int u, int p, int c) {
	color[c].pb(u);
	for (auto v: g[u]) {
		if (v == p) continue;
		dfs2 (v, u, 1-c);
	}
}

void solve() {
	cin >> n >> m >> k;
	ipgraph(n, m);
	source = -1;
	dfs1(1);

	if (source == -1) {
		dfs2 (1, 0, 0);
		int idx = (color[0].size() > color[1].size() ? 0 : 1);
		cout << 1 << endl;
		for (int i = 0; i < ceil(k/2.0); i++)
			cout << color[idx][i] << " ";
	}
	else {
		vi ans;
		int u = dest;

		while (true) {
			ans.pb(u);
			if (u == source) break;
			u = par[u];
		}

		cout << 2 << endl;
		cout << ans.size() << endl;
		for (auto v: ans) cout << v << " ";
	}
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    solve();

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
set<int> ans2;
bool vis[200005]={0};
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);
    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
            dfs(i,v,!col);
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    ans1.clear();
    dfs(1,0,1);
    for(int i=1 ; i<=n ; i++)   ans2.insert(i);
    cout<<1<<endl;
    if(ans1.size()>n/2)
        for(auto i : ans1)
            cout<<i<<" ";
    else
    {
        for(auto i : ans1)
            ans2.erase(i);
        for(auto i : ans2)
            cout<<i<<" ";
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    for(auto i : ans1)
        cout<<i<<" ";
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=(k+1)/2;
    for(int i=0 ; i<k ; i++)
    {
        if(ans1[i]==0)  { k++ ; continue;}
        cout<<ans1[i]<<" ";
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[300005]={0};
vector<int> g[300005],ans1,ansx,path;
bool vis[300005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);
    else    ansx.pb(v);
    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=(k+1)/2;
    if(ans1.size()>=k)
        for(int i=0 ; i<k ; i++)
            cout<<ans1[i]<<" ";
    else
    for(int i=0 ; i<k ;i++)
        cout<<ansx[i]<<" ";
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=ceil(k/2);
    for(int i=0 ; i<k ; i++)
        cout<<ans1[i]<<" ";
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[300005]={0};
vector<int> g[300005],path;
bool vis[300005],color[200005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col && v!=0) color[v]=1;

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=(k+1)/2;
    for(int i=0 ; k ; i++)
    {
        if(color[i])    cout<<i<<" ",k--;
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=(k+1)/2;
    for(int i=0 ; i<k ; i++)
    {
        if(ans1[i]==0)  { continue;}
        cout<<ans1[i]<<" ";
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=(k+1)/2;
    for(int i=0 ; i<k ; i++)
        cout<<ans1[i]<<" ";
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005];
void dfs(int v,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(!vis[i])
        {
            dfs(i,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,1);
    cout<<1<<endl;
    k=ceil(k/2);
    for(int i=0 ; i<k ; i++)
        if(ans1[i]==0) {k++; continue;}
        else    cout<<ans1[i]<<" ";
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[300005]={0};
vector<int> g[300005],ans1,path;
bool vis[300005];
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col && v!=0) ans1.pb(v);

    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
        {
            dfs(i,v,!col);
        }
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs(1,0,1);
    cout<<1<<endl;
    k=(k+1)/2;
    for(int i=0 ; i<k ; i++)
        cout<<ans1[i]<<" ";
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<iostream>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define mod 1000000009
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define maxn inf

using namespace std;
int n,m,k,x,y,dep[200005]={0};
vector<int> g[200005],ans1,path;
bool vis[200005]={0};
void dfs(int v,int p,bool col)
{
   // cout<<"v="<<v<<"  col="<<col<<endl;
    path.pb(v);
    vis[v]=1;
    dep[v]=path.size();
    if(col) ans1.pb(v);
    for(auto i : g[v])
    {

        if(vis[i] && dep[v]-dep[i]+1>=3 && dep[v]-dep[i]+1<=k )
        {
            cout<<2<<endl;
            cout<<dep[v]-dep[i]+1<<endl;
            for(int x=dep[i] ; x<=dep[v] ; x++)
                cout<<path[x-1]<<" ";
            exit(0);
        }
        if(i!=p && !vis[i])
            dfs(i,v,!col);
    }
    path.pop_back();
}
int main(void)
{
    cin>>n>>m>>k;
    for(int i=0 ; i<m ; i++)
    {
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    ans1.clear();
    dfs(1,0,1);
    cout<<1<<endl;
    for(auto i : ans1)
        cout<<i<<" ";
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
vector<vector<int>> edges;
vector<char> color; // 0 - white, 1 - gray, 2 - black
vector<int> parent;
int start_cycle = -1, end_cycle = -1;
const long long INF = 1e7;
bool dfs(int v) {
    color[v] = 1; // grey;
    for (auto j : edges[v]) {
        if (parent[v] == j) continue;
        if (color[j] == 0) {
            parent[j] = v;
            return (dfs(j));
        } else if (color[j] == 1) {
            end_cycle = v;
            start_cycle = j;
            return true;
        }
    }
    color[v] = 2;
    return false;
}
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    int ind_size = (k % 2 == 0 ? k / 2 : k / 2 + 1);
    edges.resize(n, {});
    color.resize(n, 0);
    parent.resize(n, - 1);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        edges[u - 1].push_back(v - 1);
        edges[v - 1].push_back(u - 1);
    }
    if (m == n - 1) { // tree
        vector<bool> visited(n, 0);
        vector<int> d(n, INF);
        queue<int> q;
        q.push(0);
        d[0] = 0;
        visited[0] = true;
        while (! q.empty()) {
            auto u = q.front();
            q.pop();
            for (auto v : edges[u]) {
                if (! visited[v]) {
                    q.push(v);
                    d[v] = d[u] + 1;
                    visited[v] = true;
                }
            }
        }
        int count = 0, num = 1;
        for (int i = 0; i < n; ++i) count += d[i] % 2;
        if (count < ind_size) num = 0; // choosing correct color
        count = 0;
        cout << 1 << "\n";
        for (int i = 0; i < n; ++i) {
            if (d[i] % 2 == num) {
                cout << i + 1 << " ";
                count += 1;
            }
            if (count == ind_size) break;
        }
        cout << "\n";
        return 0;
    }
    // not tree, so a cycle exists
    dfs(0);
    // finding cycle:
    assert(end_cycle != start_cycle);
    vector<int> dist(n, -1); // distance from start + constant for vertices in cycle, - 1 if not
    int cnt = n;
    for (int v = end_cycle; v != -1; v = parent[v]) {
        dist[v] = cnt;
        cnt -= 1;
        if (v == start_cycle) break;
        //assert(cnt >= 0);
    }
    for (int i = 0; i < n; ++i) {
        for (auto v : edges[i]) {
            int u = i;
            if (dist[u] > dist[v]) swap(u, v);
            if (dist[u] != -1 && dist[v] != -1) {
                if (v == end_cycle && u == start_cycle) continue;
                parent[v] = u; // both in cycle, bad edge
            }
        }
    }
    vector<int> cycle {start_cycle};
    for (int v = end_cycle; v != start_cycle; v = parent[v]) cycle.push_back(v);
    if (cycle.size() <= k) {
        cout << 2 << "\n" << cycle.size() << "\n";
        for (auto k : cycle) cout << k + 1 << " ";
        cout << "\n";
    } else {
        int count = 0;
        cout << 1 << "\n";
        for (int i = 0; i < cycle.size(); i += 2) {
            cout << cycle[i] + 1 << " ";
            count += 1;
            if (count == ind_size) break;
        }
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
vector<vector<int>> edges;
vector<char> color; // 0 - white, 1 - gray, 2 - black
vector<int> parent;
vector<int> dist; // dist in dfs tree from start (here zero)
int start_cycle = -1, end_cycle = -1;
const long long INF = 1e7;
bool dfs(int v) {
    color[v] = 1; // grey;
    for (auto j : edges[v]) {
        if (color[j] == 0) {
            dist[j] = dist[v] + 1;
            parent[j] = v;
            return (dfs(j));
        } else if (color[j] == 1) {
            if (parent[v] == j) continue;
            end_cycle = v;
            start_cycle = j;
            return true;
        }
    }
    color[v] = 2;
    return false;
}
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    int ind_size = (k % 2 == 0 ? k / 2 : k / 2 + 1);
    edges.resize(n, {});
    color.resize(n, 0);
    parent.resize(n, - 1);
    dist.resize(n, INF);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        edges[u - 1].push_back(v - 1);
        edges[v - 1].push_back(u - 1);
    }
    if (m == n - 1) { // tree
        vector<bool> visited(n, 0);
        vector<int> d(n, INF);
        queue<int> q;
        q.push(0);
        d[0] = 0;
        visited[0] = true;
        while (! q.empty()) {
            auto u = q.front();
            q.pop();
            for (auto v : edges[u]) {
                if (! visited[v]) {
                    q.push(v);
                    d[v] = d[u] + 1;
                    visited[v] = true;
                }
            }
        }
        int count = 0, num = 1;
        for (int i = 0; i < n; ++i) count += d[i] % 2;
        if (count < ind_size) num = 0; // choosing correct color
        count = 0;
        cout << 1 << "\n";
        for (int i = 0; i < n; ++i) {
            if (d[i] % 2 == num) {
                cout << i + 1 << " ";
                count += 1;
            }
            if (count == ind_size) break;
        }
        cout << "\n";
        return 0;
    }
    // not tree, so a cycle exists
    dist[0] = 0;
    dfs(0);
    // finding cycle:
    set<int> any_cycle {start_cycle};
    for (int v = end_cycle; v != start_cycle; v = parent[v]) any_cycle.insert(v);
    for (int i = 0; i < n; ++i) {
        for (auto v : edges[i]) {
            int u = i;
            if (dist[u] > dist[v]) swap(u, v);
            if (any_cycle.find(v) != any_cycle.end() && any_cycle.find(u) != any_cycle.end()) {
                if (v == end_cycle && u == start_cycle) continue;
                parent[v] = u;
            }
        }
    }
    vector<int> cycle {start_cycle};
    for (int v = end_cycle; v != start_cycle; v = parent[v]) cycle.push_back(v);
    if (cycle.size() <= k) {
        cout << 2 << "\n" << cycle.size() << "\n";
        for (auto k : cycle) cout << k + 1 << " ";
        cout << "\n";
    } else {
        int count = 0;
        cout << 1 << "\n";
        for (int i = 0; i < cycle.size(); i += 2) {
            cout << cycle[i] + 1 << " ";
            count += 1;
            if (count == ind_size) break;
        }
    }
    return 0;
}