55 - ZOJ Monthly, September 2006 - 1002
Now you play the following game with your friend. Your friend writes down a sequence of numbers. He chooses some continuous subsequences (for example the subsequence from the second to the fifth number inclusively), and tells you the sums of the subsequences. Then he chooses some other continuous sequences and asks you the sums of them. Can you answer the questions?
Input consists of multiple cases.
The first of each case contain three integer n, m and k(1 ≤ n ≤ 5000, 0 ≤ m, k ≤ 10000).Integer n is the length of the subsequences, m is the number of sums which your friend tells you, k is the number of questions you should answer. There are three integers a, b and s (1 ≤ a ≤ b ≤ n, -100,000,000 ≤ s ≤ 100,000,000) in the following m lines. They mean the sum of the subsequence from the a th to the b th number inclusively is s. Each of the following k lines contains two integer c, d(1 ≤ c ≤ d ≤ n).
You should output the sum of the continuous subsequences from c th to d th number in a single line for each question. If you can't find the answer output "UNKNOWN" in a single line.
Output one blank line after each test case.
Input will not be self-contradictory
10 5 5
Author: ZHANG, Zhetao