#include <iostream>

using namespace std;

void plazma_unos(long long int d_plazme[],int long long d[], long long int n){
    for(int i = 0;i<n;i++){
        scanf("%lld",&d[i]);
        scanf("%lld",&d_plazme[i]);
    }
}

int plazma (long long int d_plazme[],long long int a[], long long int d[], long long int n, long long int k){
    a[0] = 0;
    for(int i = 1;i<n;i++){
        if(d[i]== a[i]) a[i]=a[i-1] + d_plazme[i] -1;
        else if(d[i]!= a[i] && a[i-1]>=1) a[i]=a[i-1] - 1;
        else if(a[i]==0){continue;}
        printf("%lld ", i);
        if(i==k) return a[k];
    }
}

int main()
{
    long long int n, q;
    cin>>n>>q;
    long long int d[n];
    long long int a[n];
    long long int d_plazme[n];

    plazma_unos(a, d, n);

    long long int k;
    scanf("%lld", &k);

    printf("%lld", plazma(d_plazme,a, d, n, k));

    return 0;
}