The Wetland Park in SUSTech has long been a mysterious and fascinating place to visit. Satori's little sister Koishi was attracted but unfortunately lost her way inside the park, so she called Satori for help.
  There are  viewing decks in the park, which are connected by 
 plank roads build in the wetland park with some magical lychee trees growing alongside. 
  Initially the fruits along the  road can be described by a pair 
, and Koishi will eat 
 juicy lychees when she passes through the 
 road. 
  Yet, each time Koishi passes through one road, the lychee trees along every road will change from  to 
 unless its original 
 (If 
, the pair 
 will not change). 
  The sad truth is that Koishi is completely lost. Thus, she will randomly choose to start her journey from viewing deck  with probability 
. When she is at viewing deck 
, she will choose to walk through one plank road connecting it with equal probability. Satori is waiting for her at viewing deck 
. Boring as she is, she starts to calculate the expected number of lychees her little sister would eat before she reaches viewing deck 
. 
  
 
  As Satori is a master in Probability, she would change some of  or pair 
. Formally, she will perform 
 changes, for the 
 one, she would first tell you the operation type 
, then 
      If , Satori will choose a viewing deck 
 and change 
 to 
  
      If , Satori will choose a road 
 and change 
 to 
  
As Satori is quite lazy, the total number of the first operation will not exceed 100.
  Also, as Satori is a master in Cryptology, she would make her problem even more difficult by performing  operation on her previous answer. Formally, if the answer after her last change is 
, then 
      If  and you receive 
, her actual changes will be: 
 and 
  
      If  and you receive 
, her actual changes will be 
  
  Here  means module operator and 
 means exclusive or (XOR) operator. 
  Note that before Satori's first change , and the changes Satori made are accumulative. 
The first line contains three integers.
The second line containsintegers
.
The nextlines each contain four integers
, indicating the
road connects deck
and
and has pair
. Note that the roads are numbered from 1 to
.
The nextlines each has one of the two following formats:
Note that the graph is connected, and the total number of the first operation will not exceed 100.
Output
lines with exactly one integer per line, the
of which indicates the answer
998244353 after Satori's
change.
Here mod means module operator.