Father works for rail stations and his job is to supply and monitor equipment at the stations. The rail stations are connected with bidirectional railways, and each station can be reached from all other stations without forming any cycles. The equipment is measured by weight.
Father has to supply the equipment to the stations and also monitor the equipment weights frequently. He visits the stations in a manner where he checks all the station equipment from a starting station to a destination station. Sometimes, the equipment becomes unusable or problems occur, and the station master reports these issues. Father then replaces the equipment with new ones (not necessarily of the same weight) quickly.
Nowadays, Father is suffering from sickness, and he wants his two lazy sons, Alice and Bob, to take over his work. Despite their reluctance, Father divides the tasks between them. He assigns Alice to supply the equipment and Bob to monitor the equipment.
Alice and Bob are lazy, and they do not perform their tasks properly. When Father asks Alice to supply equipment to a station, Alice changes the weight of the equipment by its number of divisors.
When Father asks Bob to monitor equipment from station to station , Bob only monitors those equipment weights that he hasn't monitored earlier during this specific visit from to . He skips some stations' equipment and only checks stations further along the path from to .
Father does not care about the equipment weight changed by Alice because it is easy to figure out. However, he wants to know how many stations' equipment Bob skipped each time Father asks Bob to monitor.
There are stations numbered from to , connected by roads. One can reach every station from every other using the roads. Initially, Father gives Alice an array of weights , and Alice is supposed to supply the equipment with weight to the -th station for .
There will also be tasks. A task will be for Alice if it starts with or it will be for Bob if it starts with .
For Alice's task, a station with the number and the equipment weight will be given. Alice is supposed to supply the equipment with weight to the station .
For Bob's task, a starting station and a destination station will be given. Bob has to monitor the equipments along the simple path from to .
Since Bob always skips the weight he did monitor earlier during that specific visit from to , Father asks you to find the number of stations whose equipment Bob skipped.
The first line contains two integers and , representing the number of stations and the number of tasks, respectively.
The second line contains an array of integers, where indicates the initial equipment weight of the -th station, which is supposed to be supplied by Alice initially.
The next lines describe the connections between stations. Each line contains two integers and , indicating a connection between stations and .
Finally, there will be lines describing the tasks. Each task is either of the form or .
Constraints
For each task of type , you have to print the number of stations that Bob skipped while visiting to .
Input | Output |
---|---|
8 7 10 12 16 20 15 26 25 7 1 2 3 1 4 8 1 4 2 5 6 7 2 6 B 5 7 B 6 3 B 7 8 A 4 24 B 7 8 A 2 21 B 5 7 | 1 1 2 1 2 |
After the changes of Alice, the initial will be . |