Minions and the rooms

Rooms flip between available and unavailable over range updates; after each flip, count set partitions of N minions into the k currently available rooms, mod 880803841.

Medium6CombinatoricsIntervalsImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Gru's basement holds NN minions numbered 11 to NN. The basement has MM rooms of unlimited capacity, and every room is either available or unavailable. Each day Gru flips the state of every room in one consecutive range.

A minion can live only in an available room, and every available room must hold at least one minion. The rooms are indistinguishable: two arrangements AA and BB count as the same when, for every room in AA, some room in BB holds exactly the same set of minion numbers.

At the start every room is available. For each of the DD following days, report the number of arrangements right after Gru flips that day's range.

Input

The first line contains an integer TT, the number of test cases (T10T \le 10).

The first line of each test case contains three space separated integers NN, MM and DD (1MN1000001 \le M \le N \le 100000, 1D1000001 \le D \le 100000).

Each of the next DD lines contains two space separated integers LL and RR (1LRM1 \le L \le R \le M). On that day Gru flips the state of rooms L,L+1,,RL, L+1, \dots, R.

Output

For each query, print the number of arrangements modulo 880803841880803841 on its own line.