Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*100 for i in range(100)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+50][obx+50] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+50, sx+50, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())

Fixed submission:
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*201 for i in range(201)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+100][obx+100] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+100, sx+100, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if y < 0 or 200 < y or x < 0 or 200 < x:
            continue
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*100 for i in range(100)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+50][obx+50] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+50, sx+50, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())

Fixed submission:
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*201 for i in range(201)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+100][obx+100] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+100, sx+100, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if y < 0 or 200 < y or x < 0 or 200 < x:
            continue
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*100 for i in range(100)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+50][obx+50] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+50, sx+50, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0 and M[y+dy][x+dx] == False:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())

Fixed submission:
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*201 for i in range(201)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+100][obx+100] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+100, sx+100, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if y < 0 or 200 < y or x < 0 or 200 < x:
            continue
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())