#include "testlib.h"

#include <sstream>
#include <string>
#include <cmath>

using namespace std;

#define maxn (int)2e5
#define maxa (int)1e9

#define ADD 1
#define MUL 2

int n, a[maxn], b[maxn];
int sj[maxn], sc[maxn];
string comment;

#define EXIT(ret, com) do { comment = com; return ret; } while (0)

TResult read_data( string ans, int *sb )
{
  stringstream s(ans);
  int i;

  for (i = 0; i < n; i++)
  {
    if (i == 0)
      sb[i] = ADD;
    else
    {
      char ch;
      if (!(s >> ch))
        EXIT(_pe, "sign expected");
      if (ch == '+')
        sb[i] = ADD;
      else if (ch == '*')
        sb[i] = MUL;
      else  
        EXIT(_pe, "unknown sign");
    }

    if (!(s >> b[i]))
      EXIT(_pe, "number expected");
    if (b[i] != a[i])
      EXIT(_pe, "number should be equal to number in input at the same position");
  }
  return _ok;
}

int CheckZeroes()
{
  for (int i = 1; i < n; i++)
    if ((a[i] == 0) != (a[i - 1] == 0) && sc[i] == MUL)
      return 0;
  return 1;
}

int Calc( int l, int r, int *sgn )
{
  int sum = 0, pr;
  while (l < r)
  {
    pr = 1;
    do pr *= a[l++]; while (sgn[l] == MUL);
    sum += pr;
  }
  if (l == r) {
  	sum += a[l];
  }
  return sum;
}

void Check( int l, int r )
{
  while (l <= r && a[l] == 1)
  {
    if (l < r && sc[l + 1] != ADD)
      quitf(_wa, "ADD was expected in %d", l + 1);
    l++;
  }
  while (l <= r && a[r] == 1)
  {
    if (l < r && sc[r] != ADD)
      quitf(_wa, "ADD was expected in %d", r);
    r--;
  }
  
  int i, val = 1, f = 0;
  for (i = l; i <= r; i++)
    if (val > (int)1e9 / a[i])
      f = 1;
    else
      val *= a[i];

  if (f)
  {
    for (i = l + 1; i <= r; i++)
      if (sc[i] != MUL)
        quitf(_wa, "+inf => MUL was expected on [%d,%d]", l, r);
  }
  else
  {
    int vc = Calc(l, r, sc);
    int vj = Calc(l, r, sj);
    if (vc > vj)
      quitf(_fail, "contestant can get %d on [%d,%d] vs jury's %d\n", vc, l, r, vj);
    if (vj > vc)
      quitf(_wa, "jury can get %d on [%d,%d] vs contestant's %d\n", vj, l, r, vc);
  }
}

int main(int argc, char * argv[])
{
  registerTestlibCmd(argc, argv);

  int i;
  n = inf.readInt();
  if (!(2 <= n && n <= maxn))
    quitf(_fail, "N should be in [2, %d]", maxn);
  for (i = 0; i < n; i++)
  {
    a[i] = inf.readInt();
    if (!(0 <= a[i] && a[i] <= maxa))
      quitf(_fail, "All numbers should be in [0, %d] (but %d was found)", maxa, a[i]);
  }

  string jans = ans.readString();
  string cans = ouf.readString();

  TResult tmp;
  if ((tmp = read_data(jans, sj)) != _ok)
    quitf(_fail, "Jury's answer is incorrect: %s", comment.c_str());
  if ((tmp = read_data(cans, sc)) != _ok)
    quitf(tmp, "%s", comment.c_str());

  if (!CheckZeroes())
    quitf(_wa, "multiply by 0");
  i = 0;
  while (i < n)
    if (a[i] == 0)
      i++;
    else
    {
      int j;
      for (j = i; j < n && a[j]; j++)
        ;
      Check(i, j - 1);
      i = j;
    }

  if (cans.length() > 100)
    cans = cans.substr(0, 100) + "...";
  quitf(_ok, "%s", cans.c_str());
  return 0;
}
