Experiments with Gorlum

A creature repeats a move string K times and you report the smallest and largest squared distances from a laser over all visited points.

Medium6MathSimulationNo attempts yetTime limit1sMemory limit64 MB

Problem

Yerzhan built a laser that measures the distance to a distant object. For the test he uses Gorlum, a creature he caught in the forest. Gorlum is not bright and performs exactly five commands.

  • L: one step to the left, from (x,y)(x, y) to (x1,y)(x - 1, y).
  • R: one step to the right, from (x,y)(x, y) to (x+1,y)(x + 1, y).
  • F: one step forward, from (x,y)(x, y) to (x,y+1)(x, y + 1).
  • B: one step backward, from (x,y)(x, y) to (x,y1)(x, y - 1).
  • I: Gorlum takes a shiny ring with glowing letters out of his pocket and stays where he is.

The laser sits at (Lx,Ly)(L_x, L_y) and Gorlum starts at (Gx,Gy)(G_x, G_y). The command list TT is the string SS concatenated KK times (T=SKT = S^K), and Gorlum performs the commands of TT one by one from the front.

The laser measures the distance to Gorlum once at the start and once after each command, so it takes K×S+1K \times |S| + 1 measurements.

Report the smallest and the largest measured distance. A distance is usually irrational, so this problem asks for the squared distance instead. The squared distance is always an integer, the point with the smallest square is the closest point, and the point with the largest square is the farthest one.

Input

The first line contains a natural number KK (1K1051 \le K \le 10^5).

The second line contains the string SS. It consists only of L, R, F, B, I, and 1S1041 \le |S| \le 10^4.

The third line contains the laser coordinates LxL_x and LyL_y, separated by a space.

The fourth line contains Gorlum's starting coordinates GxG_x and GyG_y, separated by a space.

Every coordinate is an integer with absolute value at most 10410^4.

Output

Print the smallest and the largest squared distance on one line, separated by a space. Both values fit in a signed 64-bit integer.