from sys import stdin
from bisect import *
input = stdin.readline
N, M = map(int,input().split())
S = input()
R = []
B = []
for idx in range(N):
if S[idx] == 'R':
R.append(idx)
elif S[idx] == 'B':
B.append(idx)
R_len = len(R)
B_len = len(B)
for _ in range(M):
l, r = map(int,input().split())
r_idx_1 = bisect_left(R,l)
r_idx_2 = bisect_left(R,r)
# print(r_idx_1,r_idx_2,1212,R)
if( (abs(r_idx_1-r_idx_2)<=1 and r_idx_2 == R_len) or r_idx_1==R_len):
print(-1)
continue
b_idx_1 = bisect_left(B,l)
b_idx_2 = bisect_left(B,r)
if((abs(b_idx_1-b_idx_2)<=1 and b_idx_2==B_len) or b_idx_1==B_len):
print(-1)
continue
if(b_idx_2 == B_len):
b_idx_2-=1
a, b = R[r_idx_1], R[r_idx_1+1]
c, d = B[b_idx_2-1], B[b_idx_2]
if(l<=a<b<c<d<=r):
print(a,b,c,d)
else:
print(-1)