#include "infection.h"
#include <bits/stdc++.h>
#include <vector>
#include <utility>

using namespace  std;

#define int long long

const int maxn=1e5+10;
const int mod=1e9+7;
vector<int> solve(vector<pair<int, int>> R,vector<long long> D,vector<int> S,vector<int> T,vector<bool> I)
{
    ///Linija Di=0
    int n=R.size()+1;
    int m=D.size();
    vector<int>ans;
    bool bolen[n];
    memset(bolen,0,sizeof bolen);
    for (int idx=0;idx<m;idx++) {
        if (I[idx]==1) {
            bolen[S[idx]]=1;
        }
    }
    for (int idx=0;idx<m;idx++) {
        int dist=abs(S[idx]-T[idx]+1);
        if (bolen[S[idx]]==1) {
            ans.push_back(dist);
        }
        else {
            ans.push_back(0);
        }
    }
    return ans;
}