#!/usr/bin/env python3


def main():
    guards = list()
    incidents = list()

    line0 = [int(i) for i in input().split()]
    n_guards = line0[0]
    n_inc = line0[1]

    for i in range(n_guards):
        guards.append(
            [int(i) for i in input().split()]
        )

    for i in range(n_inc):
        incidents.append(
            [int(i) for i in input().split()]
        )


    for inc in incidents:
        shortest_dist = None
        for g in guards:
            dist = ( (inc[0] - g[0]) ** 2 + (inc[1] - g[1]) ** 2 ) ** 0.5
            if shortest_dist is None or dist < shortest_dist:
                shortest_dist = dist
        print(round(shortest_dist))



if __name__ == '__main__':
    main()
