速度也还可以
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <stdlib.h>
#include <cctype>
#define rep1(i,s,e) for(int i = (s);i<(e);++i)
#define rep2(i,s,e) for(int i = (s);i<=(e);++i)
#define maxn 100100
#define INF 1000000007
#define ls (root<<1)
#define rs (root<<1|1)
#define M L+(R-L)/2
using namespace std;
int n,m;
struct song
{
long long c;
long long t;
long long start;
long long end;
}s[maxn];
//有一个简单的优化。。。
//因为题目告诉我们:It is guaranteed that vi < vi + 1 (i<m)
//所以我们每次没必要从第一首歌开始找start和end而是保存上一次查找的结果。。从上一次的结果处开始查找
int main()
{
//freopen("in.txt","r",stdin);
while(scanf("%d%d",&n,&m)==2)
{
int sum = 0;
for(int i = 1;i<=n;++i)
{
s[i].start = sum;
scanf("%I64d%I64d",&s[i].c,&s[i].t);
sum += s[i].c*s[i].t;
s[i].end = sum;
}
int b = 1;
for(int i = 0;i<m;++i)
{
int time;
scanf("%I64d",&time);
for(int j = b;j<=n;++j)
{
if(time>=s[j].start&&time<=s[j].end)
{
b = j;
printf("%d\n",j);
break;
}
}
}
}
return 0;
}