require 'set'

reverse = { ?N => ?S, ?S => ?N, ?E => ?W, ?W => ?E }

n, x0, y0, t = gets.split.map(&:to_i)
junction = {}
n.times do
  x1, y1, x2, y2 = gets.split.map(&:to_i)
  dx, dy = x2 - x1, y2 - y1
  l = dx.abs + dy.abs
  dx /= l
  dy /= l
  dir = dx > 0 ? ?E :
        dx < 0 ? ?W :
        dy > 0 ? ?N :
                 ?S
  l.times do
    (junction[[x1, y1]] ||= Set.new) << dir
    (junction[[x1 + dx, y1 + dy]] ||= Set.new) << reverse[dir]
    x1 += dx
    y1 += dy
  end
end

initial_states = Set[*junction[[x0, y0]].map {|dir| [x0, y0, dir] }]

def diff(dir)
  dx = (dir == ?E ? 1 : dir == ?W ? -1 : 0)
  dy = (dir == ?N ? 1 : dir == ?S ? -1 : 0)
  [dx, dy]
end

t.times do
  buckets = (0..9).map { Set.new }
  dist, observed_dir = gets.chomp.split
  dist = dist.to_i
  initial_states.each do |x, y, dir|
    dx, dy = diff(dir)
    buckets[dist - 1] << [x + dx, y + dy, dir]
  end

  9.downto(1) do |d|
    buckets[d].each do |x, y, dir|
      junction[[x, y]].each do |next_dir|
        next if next_dir == reverse[dir]
        dx, dy = diff(next_dir)
        buckets[d - 1] << [x + dx, y + dy, next_dir]
      end
    end
  end

  initial_states = Set.new
  buckets[0].each do |x, y, dir|
    if dir == observed_dir
      junction[[x, y]].each do |next_dir|
        next if next_dir == reverse[dir]
        initial_states << [x, y, next_dir]
      end
    elsif junction[[x, y]].include?(observed_dir)
      initial_states << [x, y, observed_dir] unless observed_dir == reverse[dir]
    end
  end
end

initial_states.map {|a| a[0..1] }.uniq.sort.each {|a| puts a * " " }

