INPUT n, m
FOR i = 1 TO n
    INPUT a(i), b(i)
    IF a(i) > b(i) THEN
        c = a(i)
        a(i) = b(i)
        b(i) = c
    END IF
NEXT i

FOR j = 1 TO m
    INPUT x(j)
NEXT j

FOR j = 1 TO m
    k = 0
    FOR i = 1 TO n
        IF x(j) >= a(i) AND x(j) <= b(i) THEN k = k + 1
    NEXT i
    PRINT k
NEXT j
