cswork / OAOpen practice workspace

CrusoeOA #1

Interval Usage with Non-Overlapping Overrides

Estimated MediumJudge-ready

Topics (AI-labelled)Prefix & RangesSimulation

Intervals with usage=1 are unioned; usage=0 does not clear anything; non-overlapping override intervals overwrite the usage result.

This site's standard input/output format and supplementary bounds follow this problem's description.

Input

The input is D and U, followed by U lines l r v; then O, followed by O lines l r v. 1≤D≤2×10^5, U,O≤2×10^5; intervals are closed and lie within [1,D], v∈{0,1}; override intervals are pairwise non-overlapping.

Output

Output a 0/1 string of length D.

Example 1

Input:

10
2
1 2 1
4 10 1
1
2 4 0

Output:

1000111111

Example 2

Input:

3
1
1 3 0
0

Output:

000

Example 3

Input:

1
5
1 1 1
1 1 0
1 1 0
1 1 0
1 1 0
1
1 1 1

Output:

1

Editorial

Loading solution…