Tobby Stones

Tobby is an intelligent Boston Terrier who has a garden. In his garden he has N stones which, like Tobby, are either black or white. The stones are organized in a row and numbered from 0 to N - 1. Tobby likes to change his stones quite a lot and he does so by taking a contiguous part of his stones, from integer indexes I to J, and making some changes to all stones located between those two indexes (including the stones at I and J). Given a list of changes that Tobby makes to his garden, your task is to answer queries about the number of black and white stones in his garden. Initially all stones in Tobby’s garden are white. Input The input contains several test cases. Each test case starts with a line in which there are two positive integers N (1 ≤ N ≤ 106) and M (1 ≤ M ≤ 106) that represent, respectively, the number of stones in Tobby’s garden and the number of changes and queries to answer. Then M lines follow, each containing either a change or a query. Each of those lines starts with an integer Q (0 ≤ Q ≤ 3): •IfQis0,thenthelineisaquery,inthatcasetwonumbersfollow: I(0≤I<N)andJ (I ≤ J < N), indicating the start and end positions to consider to answer the query. • If Q is 1, then the line is a change of type reverse, in that case two integers follow: I (0 ≤ I < N) and J (I ≤ J < N), indicating that Tobby wants to reverse the color of all stones between those indexes so that the color of stone I + K becomes the color of stone J − K and the color of stone J − K becomes the color of stones I + K for all integer K such that 0 ≤ K and I + K < J − K. • IfQis2,thenthelineisachangeoftypeflipcolor,inthatcasetwointegersfollow:I(0≤I<N) and J (I ≤ J < N), indicating that Tobby wants to change the color of all stones between those indexes so that all white stones become black stones and all black stones become white stones. • If Q is 3, then the line is a change of type set color, in that case three integers follow: I (0 ≤ I < N), J (I ≤ J < N) and C (0 ≤ C ≤ 1) indicating that Tobby wants to set the color of all stones between indexes I and J. If C is 0, then all stones between those two indexes should become black, while if it is 1 they should become white. Output For each query in the input, you should print a single line with two integers: the number of black stones and the number of white stones between the indexes I and J given in the query. Sample Input 10 7 009 3040 004 109 059 259 039

2/2 100 1 0 0 50 Sample Output 0 10 50 50 07 0 51