#include<stdio.h>
#include<string.h>
#define N 200000
int repIndex = 0;
int getRep(int a[], int n, int visit[]){
    memset(visit, 0, N * sizeof(int));
    int i = 1, count = 0;;
    while(visit[i] != 1){
        visit[i] = 1;
        i = a[i];
        count++;
    }
    repIndex = i;
    i = 1;
    int count2 = 0;
    while(i != repIndex){
        visit[i] = 1;
        i = a[i];
        count2++;
    }
    count = count - count2;
    return count;
}
int main(){
    int n;
    long long int k;
    int a[N], visit[N];
    scanf("%d %lld", &n, &k);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    int rep = getRep(a, n, visit);
    printf("%d %d\n", rep, repIndex);
    int i = 1, count = 0;
    while(i != repIndex){
        i = a[i];
        count++;
    }
    if(k < count){
        i = 1;
        count = 0;
        while(count < k){
            i = a[i];
            count++;
        }
        printf("%d", i);
        return 0;
    }
    k -= count;
    k %= rep;
    count = 0;
    while(count < k){
        i = a[i];
        count++;
    }
    printf("%d", i);
    return 0;
}