nums = [int(x) for x in input().split(" ")]
count = nums[0]
engines = [-1 for i in range(count)]
start_cnt = nums[1]
min_time = float("inf")
for i in range(start_cnt):
nums1 = [int(x) for x in input().split(" ")]
engines[nums1[1]] = nums1[0]
min_time = min(min_time, nums1[0])
def activate(index, time, count):
global engines
left = index - 1
if index == 0:
left = count - 1
right = index + 1
if index == count - 1:
right = 0
if engines[left] == -1:
engines[left] = time
if engines[right] == -1:
engines[right] = time
def find(start):
global engines
flag = True
while flag:
for i in range(len(engines)):
if engines[i] == start:
activate(i, start + 1, len(engines))
start += 1
active_cnt = 0
for i in range(len(engines)):
if engines[i] != -1:
active_cnt += 1
if active_cnt == len(engines):
flag = False
max_time = engines[0]
for i in range(len(engines)):
if engines[i] > max_time:
max_time = engines[i]
count = 0
result = ""
for i in range(len(engines)):
if max_time == engines[i]:
result += str(i) + " "
count += 1
print(count)
print(result[:-1])
find(min_time)