我的代码为啥输出不了数据
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int r = scanner.nextInt();
int y = scanner.nextInt();
int g = scanner.nextInt();
int n = scanner.nextInt();
int time = 0;
for(int i = 0;i<n;i++) {
int k =scanner.nextInt();
int t =scanner.nextInt();
int dex = time;
while(t-dex<=0){
if(k==1){k=3;dex-=t;t=g;}
if(k==2){k=1;dex-=t;t=r;}
if(k==3){k=2;dex-=t;t=y;}
}
if(dex!=0){
t-=dex;
dex = 0;
}
if(k==0) {
time+=t;
}else if(k==1) {
time+=t;
}
else if(k==2) {
time+=t+r;
}else {
time+=0;
}
}
System.out.println(time);
}}