include Math
EPS = 1e-10

class AngleInterval
	def initialize(x0, y0, x1, y1, x2, y2)
		t1 = atan2(y1 - y0, x1 - x0)
		t2 = atan2(y2 - y0, x2 - x0)
		t1, t2 = t2, t1 if t2 < t1
		if t2 - t1 >= PI
			t1, t2 = t2, t1 + 2 * PI
		end
		@min, @max = t1, t2
	end

	def &(other)
		r = self.class.new(0, 1, 3, 2, 4, 5)	
		if empty? || other.empty?
			r.min = Float::INFINITY
			r.max = -Float::INFINITY
			return r
		end
		a = other.min
		b = other.max
		until b <= @max
			a -= 2 * PI
			b -= 2 * PI
		end
		until b >= @min
			a += 2 * PI
			b += 2 * PI
		end
		if a <= @min && @min <= b && b <= @max
			r.min = @min
			r.max = b
		elsif @min <= a && a <= @max && @max <= b
			r.min = a
			r.max = @max
		elsif @min <= a && b <= @max
			r.min = a
			r.max = b
		elsif a <= @min && @max <= b
			r.min = @min
			r.max = @max
		else
			r.min = Float::INFINITY
			r.max = -Float::INFINITY
		end
		r
	end

	def empty?
		@max - @min < EPS
	end

	attr_accessor :min, :max
end

def f(x0, y0, lines, interval = nil)
	return 1 if lines.empty? && interval && !interval.empty?		
	sum = 0
	lines.each do |l|
		x1, y1, x2, y2 = l
		r = AngleInterval.new(x0, y0, x1, y1, x2, y2)
		
		new_interval = (interval ? interval & r : r)
		next if new_interval.empty?

		t1 = atan2(y2 - y1, x2 - x1)
		new_lines = lines - [l]
		raise if new_lines.size != lines.size - 1
		new_lines.map! do |x3, y3, x4, y4|
			dx = x3 - x1
			dy = y3 - y1
			t2 = atan2(dy, dx)
			dt = -2 * (t2 - t1)
			x = [x1 + cos(dt) * dx - sin(dt) * dy, y1 + sin(dt) * dx + cos(dt) * dy]

			dx = x4 - x1
			dy = y4 - y1
			t2 = atan2(dy, dx)
			dt = -2 * (t2 - t1)
			y = [x1 + cos(dt) * dx - sin(dt) * dy, y1 + sin(dt) * dx + cos(dt) * dy]

			[*x, *y]
		end
		sum += f(x0, y0, new_lines, new_interval)
	end
	sum
end

loop do
	n = gets.to_i
	break if n == 0
	count = 0
	sx, sy = gets.split.map(&:to_i)
	points = (1..n).map { gets.split.map(&:to_i) }
	orig_lines = (points + [points[0]]).each_cons(2).to_a.map(&:flatten)
	p f(sx, sy, orig_lines)
end