#include <stdio.h>
#include <string.h>
int main() {
char s[1000000] = {'\0'};
scanf("%s", s);
int len = strlen(s);
int n, i, a;
scanf("%d", &n);
int step = -1;
for (i = 0; i < n; i++) {
scanf("%d", &a);
step += a;
if (s[step] == '>'&&s[step+1]=='>'&&s[step+2]=='>') {
while (s[step] == '>') {
step++;
}
}
else if (s[step] == '*'&&s[step+1]=='*'&&s[step+2]=='*') {
int num = 0;
while (s[step] == '*') {
num++;
step++;
}
step -= num * 2;
}
if (step < 0) {
step = 0;
}
else if (step >= len) {
step = len - 1;
}
}
if (step < 0) {
printf("1 %d\n", len-1);
} else if (step >= len) {
printf("%d 0\n", len);
} else {
printf("%d %d\n", step + 1, len - 1 - step);
}
return 0;
}
``` ```