import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; int[] a, b; scan(n); a = new int[](n); b = new int[](n); iota(n).each!(i => scan(a[i], b[i])); int m; scan(m); auto cnt = new int[](m); foreach (i ; 0 .. m) { int xi, yi; scan(xi, yi); foreach (j ; 0 .. n) { if (xi <= a[j] && yi >= b[j]) cnt[i]++; } } debug { writeln(cnt); } auto cm = cnt.reduce!max; if (cm == 0) { writeln(0); return; } auto ans = iota(m).filter!(i => cnt[i] == cm).map!(x => x + 1).array; ans.each!(i => writeln(i)); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; auto line = readln().splitter(); foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }