You have threads
that are writing to a circular data structure with positions (each position storing a
single integer), and all of the threads write integer per second. Each thread
starts writing at time
, from position
in the data
structure, and it writes occurrences of an integer to the circular data structure.
The thread will write to each position sequentially (starting
from , and then
writing to , , and so on). If it reaches index , the next index will be
since the data
structure is circular. If two or more threads try to write
different integers at the same time to the same position, a
race condition occurs, which means the value at that spot is
indeterminate, because it could be one of many values depending
on which thread succeeded the write operation. However, if the
threads all write the value to the same position at the same
time, the value at that position will be since there is no ambiguity.
For example, in the first sample case, the end result of the
data structure is . Even though threads and write to the same spots at the
same time, this does not cause a race condition since they
write the same integer.
On the other hand, in the second sample case, the end result of
the data structure is where represents an indeterminate
character, since two threads write different characters at the
same time to the same position.
The values that the threads can write are in the range
. At the end of all
the thread writes, for each integer , there are occurrences of . Given that every position in the
data structure was initialized to before any threads started
writing, print all
in order, and at the end, print the number of indeterminate
characters.
Input
The first line of the input contains three space-separated
integers, , , . These represent the number of
threads, the size of the circular data structure, and the
number of integers that the threads can write to the data
structure respectively.
Another lines follow
with four space-separated integers ,
, , . These represent the time that thread
starts writing, the
position it starts writing from, the number of values it
writes, and the number it writes to each position. Each thread
writes integer per
second.
Output
Output
space-separated numbers where represents the amount of times
the number appears in
the data structure after all threads finish writing for
.
represents the
amount of times an indeterminate character appears in the data
structure after all threads finish writing.
Sample Input 1 |
Sample Output 1 |
3 5 2
0 0 1 1
1 2 2 1
1 2 2 1
|
2 3 0
|
Sample Input 2 |
Sample Output 2 |
3 5 2
0 0 1 1
1 2 2 0
1 2 2 1
|
2 1 2
|