/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String input
= "(-1 +2 -3 -4 -5 -6 -7 +8 +9 +10 +11 +12 +13 +14 +15 -16 -17 -18 +19 -20 +21 +22 -23 -24 +25 -26 -27 +28 -29 -30 +31 +32 +33 -34 -35 +36 +37 +38 +39 -40 +41 +42 -43 +44 +45 +46 -47 +48 +49 +50 -51 +52 +53 +54 -55 -56 -57 +58 -59 -60 -61 +62 -63 +64 +65 -66 -67)"; String indices
= "116, 118, 73, 72"; input = input.substring(1, input.length() - 1);
String[] input1
= input.
split(" "); int[] numbers = new int[input1.length];
int n = input1.length;
for (int i = 0; i < n; i++){
numbers
[i
] = Integer.
parseInt(input1
[i
]); }
String[] indices1
= indices.
split(", "); int[] indices2 = new int[4];
for (int i = 0; i < 4; i++){
indices2
[i
] = Integer.
parseInt(indices1
[i
]) - 1; }
int[] cycle = new int[n*2];
for (int i = 0; i < n; i++) {
if (numbers[i] > 0) {
cycle[i*2] = (numbers[i] - 1)*2;
cycle[i*2 + 1] = (numbers[i] - 1)*2 + 1;
}
else {
cycle[i*2] = (numbers[i]*(-1) - 1)*2 + 1;
cycle[i*2 + 1] = (numbers[i]*(-1) - 1)*2;
}
}
int from = 0;
int to = 0;
n = n*2;
for (int i = 0; i < n; i++) {
if (cycle[i] == indices2[0]) {
from = i;
}
if (cycle[i] == indices2[2]) {
to = i;
}
}
int i = from;
while (i != (n + to - 1)%n) {
if (cycle[(n + i)%n] < cycle[(n + i + 1)%n]) {
cycle1 = cycle1 + "+" + (cycle[(n + i)%n]/2 + 1) + " ";
}
else {
cycle1 = cycle1 + "-" + (cycle[(n + i)%n]/2 + 1) + " ";
}
i = (n + i + 2)%n;
}
cycle1 = cycle1.substring(0, cycle1.length() - 1) + ")";
i = (n + to + 1)%n;
while (i != (n + from)%n) {
if (cycle[(n + i)%n] < cycle[(n + i + 1)%n]) {
cycle2 = cycle2 + "+" + (cycle[(n + i)%n]/2 + 1) + " ";
}
else {
cycle2 = cycle2 + "-" + (cycle[(n + i)%n]/2 + 1) + " ";
}
i = (n + i + 2)%n;
}
cycle2 = cycle2.substring(0, cycle2.length() - 1) + ")";
}
}