using System; using System.Collections.Generic; using System.Linq; namespace C_AinS { internal class Program { static void Main(string[] args) { string[] param1 = Console.ReadLine().Split(' '); int n = int.Parse(param1[0]); int m = int.Parse(param1[1]); List<(int L, int R, int X, int Y)> list = new List<(int L, int R, int X, int Y)>(); for(int i = 0; i < n; i++) { string[] param2 = Console.ReadLine().Split(' '); list.Add((int.Parse(param2[0]), int.Parse(param2[1]), int.Parse(param2[2]), int.Parse(param2[3]))); } List aList = Console.ReadLine().Split(' ').ToList().ConvertAll(x => int.Parse(x)); int[] result = new int[m]; for (int i = 0; i < m; i++) { int count = 0; for (int j = 0; j < n; j++) { if (list[j].L <= aList[i] && aList[i] <= list[j].R) { if((aList[i] - list[j].Y) % list[j].X == 0) { count++; } } } Console.WriteLine(count); } } } }