using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]), q = int.Parse(s[1]);

            for (int i = 0; i < n;i++) s = Console.ReadLine().Split();
            for (int i = 0; i < q; i++) s = Console.ReadLine().Split();

            for (int i = 0; i < q; i++) Console.WriteLine(0);

            Console.ReadLine();
        }
    }
}