import sys input = sys.stdin.readline def int_input(): return map(int,input().split()) n, q = int_input() s = input() def find_pair(x): count_dis = 1 if s[x - 1] == "(": for i in range(1, n): if s[x - 1 + i] == "(": count_dis += 1 else: count_dis -= 1 if count_dis == 0: return x + i else: for i in range(1, n): if s[x - 1 - i] == ")": count_dis += 1 else: count_dis -= 1 if count_dis == 0: return x - i def find_set_b(x): count_dis = 0 for i in range(1, x): if s[x-1-i]==")": count_dis -= 1 else: count_dis += 1 if count_dis == 1: return x - i def find_set_t(x): count_dis = 0 for i in range(1, n - x + 1): if s[x-1+i]=="(": count_dis -= 1 else: count_dis += 1 if count_dis == 1: return x + i def compare_2set(x, y): if min(x) <= min(y) and max(x) >= max(y): return min(x), max(x) elif min(y) <= min(x) and max(y) >= max(x): return min(y), max(y) else: None for _ in range(q): a, b = int_input() x, y = (a, find_pair(a)), (b, find_pair(b)) if ret:= compare_2set(x, y): print(*ret) else: top, bottom = max(*x, *y), min(*x, *y) a_b = find_set_b(bottom) a_t = find_set_t(top) if a_b and a_t: print(a_b, a_t) else: print(-1)