#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
int l, r, sum,_max;
}dp[200005*4];
int w;
void Creat(int l, int r, int i)//初始化线段树
{
dp[i].l = l;
dp[i].r = r;
dp[i].sum = dp[i]._max = 0;
if (l == r)//当为最小子区间时输入值
{
dp[i]._max = w;
return;
}
int mid = (l + r) / 2;//分半
Creat(l, mid, i * 2);
Creat(mid + 1, r, i * 2 + 1);
dp[i]._max = max(dp[i * 2]._max, dp[i * 2 + 1]._max);//第i层的最大值更新
}
void Change(int a, int b, int i)//将第a个位置改成b
{
if (dp[i].l == dp[i].r)
{
dp[i]._max = b;
return;
}
int mid = (dp[i].l + dp[i].r) / 2;
if (a <= mid)
{
Change(a, b, i * 2);
}
else
{
Change(a, b, i * 2 + 1);
}
dp[i]._max = max(dp[i * 2]._max, dp[i * 2 + 1]._max);//修改值
}
int Find(int x,int l, int r, int i)
{
if (l == r)
{
dp[i]._max -= x;
return l;
}
int mid = (dp[i].l + dp[i].r) / 2;
int ret;
if (x <= dp[i * 2]._max)
{
ret = Find(x, l, mid, i * 2);//不能直接返回,还要进行操作
}
else
ret = Find(x, mid + 1, r, i * 2 + 1);
dp[i]._max=max(dp[i * 2]._max, dp[i * 2 + 1]._max);
return ret;
}
int main()
{
int h, n;;
while (cin >> h >> w >> n)
{
if (h > n)
h = n;
Creat(1, h, 1);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
if (x > dp[1]._max)
cout << "-1" << endl;
else
{
cout << Find(x, 1, h, 1) << endl;
}
}
}
return 0;
}