Under construction

Still being built. Things may change

Driving in the Mountains

Interview

Time limit1sMemory limit1024 MB

Summary
Given ground heights and Juta's height changes per meter, output whether she is on the ground, on a viaduct, or in a tunnel after each meter.
Level

Easy3 of 10

Topics
Implementation, Prefix sum
Solved
No attempts yet

Problem

Juta visited Norway, which has many mountains. Her smartphone recorded how her trip went up and down. Every meter, the phone reported how many units she moved up or down. Juta started her trip on the ground, but sometimes she drove along a viaduct above the ground or through a tunnel below it. You are given the height of the ground above sea level along Juta's trip and the notifications from her phone. For each meter, find whether Juta was on the ground, in the air on a viaduct, or underground in a tunnel at that moment.

Input

The first line contains an integer NN, the length of the trip in meters (1≤N≤100 0001 \le N \le 100\,000). The second line contains N+1N+1 integers H0,H1,…,HNH_0, H_1, \dots, H_N (−1 000 000 000≤Hi≤1 000 000 000-1\,000\,000\,000 \le H_i \le 1\,000\,000\,000), the height of the ground above sea level at the start of the trip and after each meter. The third line contains NN integers D1,D2,…,DND_1, D_2, \ldots, D_N (−10 000≤Di≤10 000-10\,000 \le D_i \le 10\,000), where DiD_i is how much Juta's height changed during the ii-th meter. You may assume Juta's height above sea level never leaves the range −2 000 000 000-2\,000\,000\,000 to 2 000 000 0002\,000\,000\,000.

Output

Print a single line of NN characters. The ii-th character tells where Juta is after passing the ii-th meter: 'M' for the ground, 'V' for a viaduct in the air, or 'T' for a tunnel underground.

Examples1

  1. Example 1

    Input
    7
    100 101 103 104 104 103 103 102
    +1 +2 0 0 +1 -1 -1
    
    Expected output
    MMTTVMM