#K63672. RGB Filter Application

    ID: 31806 Type: Default 1000ms 256MiB

RGB Filter Application

RGB Filter Application

In this problem, you are given the initial RGB (Red, Green, Blue) values of a color and a sequence of filters. Each filter is represented as a pair ((q, v)), where (q) identifies the color channel (0 for red, 1 for green, and 2 for blue) and (v) is the value to add to that channel. After applying each filter sequentially, the value of each channel is clamped to the range ([0, 255]). The clamping operation can be expressed as:

[ x = \min(255, x + v)]

Your task is to compute the final RGB values after all filters have been applied.

Input is provided via standard input and output should be printed to standard output.

inputFormat

The first line contains three integers (R), (G), and (B) representing the initial red, green, and blue values respectively. The second line contains a single integer (n) which is the number of filters. Each of the following (n) lines contains two integers (q) and (v), where (q) indicates the color channel (0 for red, 1 for green, 2 for blue) and (v) is the value to add to that channel.

outputFormat

Output the final RGB values after applying all filters. The three integers should be printed on a single line separated by spaces.## sample

100 150 200
3
0 60
1 50
2 10
160 200 210