from bisect import bisect_left N, Q = map(int, input().split()) s = input().strip() p = [0] * N st = [] for i, x in enumerate(s): if x == '(': st.append(i) else: p[i] = st[-1] p[st[-1]] = i st.pop() a = [(i, p[i]) for i, x in enumerate(s) if x == '('] for _ in range(Q): x, y = map(int, input().split()) x -= 1; y -= 1 i = bisect_left(a, (x, y)) while i >= 0: if a[i][0] <= x and a[i][1] >= y: break i -= 1 if i < 0: print(-1) else: print(a[i][0] + 1, a[i][1] + 1)