Why am I getting a runtime error when the code is running perfectly fine?

,
#include <stdio.h>
#include<string.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++){
	    char ch[100000];
	    int flag=0;
	    scanf("%s",&ch);
	    for(int i=0;i<strlen(ch)-2;i++){
	        if((ch[i]=='0'&&ch[i+1]=='1'&&ch[i+2]=='0')||(ch[i]=='1'&&ch[i+1]=='0'&&ch[i+2]=='1'))
	            flag=1;
	            
	    }
	    if(flag==1)
	         printf("Good\n");
	    else
	            printf("Bad\n");
	}
	return 0;
}


you have used undefined variables first define them before using them example ā€œiā€