A meteor shower passed through the kingdom of Woll, which led the people to speculate that it was a punishment from the gods. Many gathered at the door of the mage Hongly and prayed to him to protect them with his spells. The enthusiastic Hongly quickly granted them their blessing.
Hongly's spell requires the use of $n$ magic towers lined up in a straight line, numbered as $1, 2, 3, ..., n$. Each tower requires some magic value to cast this spell. And each tower has an initial magic value of $0$ . Hongly needs to add some magic ingredients to the magic tower in order to increase its magic values. When $1$ unit of magic ingredients is added to a tower, it will increase the magic value of all nearby magic towers by $1$ within a radius of $k$, in which $k$ is called effective radius. For example, assuming the $i$-th magic tower is added with $1$ unit of magic ingredients, when $k=1$, only magic tower $i$ will add its magic value by $1$, when $k=2$, magic tower $i-1, i, i+1$ will increase their magic values by $1$, and so on. The effective radius for all towers is the same. For this spell to protect the people, the $i$-th magic tower needs at least $p_{i}$ points of magic value.
However, magic is not free to be used at will, and when there are too many magic ingredients in a range, it can lead to a big explosion. So there are $q$ restrictions among Hongly's magic towers. The $i$-th restriction contains three integers $L_{i},R_{i},B_{i}$, which means that the sum of the magic ingredients in the magic towers $[L_{i},R_{i}]$ cannot be greater than $B_{i}$.
Hongly is glad to help the villagers but is worried about the explosion. Now he wants to know if there is a way to place the ingredients that will meet the magic value requirements of all magic towers for using the spell while avoiding an explosion. If so, he would also like to know the minimum value of magic ingredients that need to be used.