import java.util.*;
import java.io.*;

public class billboard_gk_check {
    static Scanner in;
    static PrintWriter out;

    static final int MAX_N = 200000;
    static final int MAX_C = 1000000000;

    public void run() {
        int height = in.nextInt();
        int width = in.nextInt();
        int n = in.nextInt();

        assert 1 <= width && width <= MAX_C;
        assert 1 <= height && height <= MAX_C;
        assert 1 <= n && n <= MAX_N;

        height = Math.min(height, n);

        int m = 1;
        while (m < height) {
            m *= 2;
        }

        int[] tree = new int[2 * m];
        for (int i = 0; i < height; i++) {
            tree[m + i] = width;
        }
        for (int i = tree.length / 2 - 1; i > 0; i--) {
            tree[i] = tree[i * 2];
        }

        for (int i = 0; i < n; i++) {
            int w = in.nextInt();
            if (tree[1] >= w) {
                int p = 1;
                while (p < m) {
                    assert (tree[p] >= w);
                    p *= 2;
                    if (tree[p] < w) {
                        p++;
                    }
                }
                out.println(p - m + 1);
                tree[p] -= w;
                while (p > 1) {
                    p /= 2;                    
                    tree[p] = Math.max(tree[2 * p], tree[2 * p + 1]);
                }
            } else {
                out.println(-1);
            }
        }
    }

    public static void main(String[] args) throws Exception {        
        in = new Scanner(new File("billboard.in"));
        out = new PrintWriter("billboard.out");

        new billboard_gk_check().run();

        in.close();
        out.close();
    }
}
