#include #include #include #include #include #include #include int main(){ int n,i,j,t,a[100000],k; scanf("%d",&n); char* *genes = malloc(sizeof(char*) * n); for(int genes_i = 0; genes_i < n; genes_i++){ genes[genes_i] = (char *)malloc(10240 * sizeof(char)); scanf("%s",genes[genes_i]); } int *health = malloc(sizeof(int) * n); for(int health_i = 0; health_i < n; health_i++){ scanf("%d",&health[health_i]); } int s; scanf("%d",&s); for(int a0 = 0; a0 < s; a0++){ int first,sum=0; int last; char* d = (char *)malloc(512000 * sizeof(char)); scanf("%d %d %s",&first,&last,d); for(int i=first;i<=last;i++){ // printf("%c \n",d[i]); for(int j=0;ja[j+1]){ t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } } printf("%d %d\n",a[0],a[k-1]); return 0; }