#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int fr[150005];

vector<int> solve(vector<pair<int, int>> r, vector<long long> d, vector<int> s, vector<int> t, vector<bool> ii)
{
    int n = (int)r.size() + 1; int m = (int)d.size();

    for(int i = 0; i < m; i++)
        if(ii[i]) fr[s[i]] = 1;

    vector<int> ans; ans.clear();
    for(int i = 0; i < m; i++)
        if(fr[s[i]])
            ans.push_back(abs(t[i] - s[i] + 1));

    return ans;
}