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

namespace ConsoleApp32
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split();
            int N = int.Parse(a[0]); 
            int Q = int.Parse(a[1]); 

 
            long[] d = new long[N];
            long[] p = new long[N];
            for (int i = 0; i < N; i++)
            {
                var line = Console.ReadLine().Split();
                d[i] = long.Parse(line[0]);
                p[i] = long.Parse(line[1]);
            }

    
            long[] z = new long[Q];
            for (int i = 0; i < Q; i++)
            {
                z[i] = long.Parse(Console.ReadLine());
            }

    
            long[] s = new long[N];
            s[0] = p[0];
            for (int i = 1; i < N; i++)
            {
                s[i] = s[i - 1] + p[i];
            }

          
            foreach (long k in z)
            {
              
                int left = 0, right = N - 1;
                int result = -1;

                while (left <= right)
                {
                    int mid = (left + right) / 2;
                    if (d[mid] <= k)
                    {
                        result = mid;
                        left = mid + 1; 
                    }
                    else
                    {
                        right = mid - 1;
                    }
                }

                if (result == -1)
                {
                    Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(s[result]);
                }
            }
        }
    }
}