import java.io.*;
import java.lang.*;
import java.util.*;

public class C_h {
  public static final int MAX_N = 10;
  public static DataInputStream in = new DataInputStream(System.in);

  static int fflinsolve(int A[][], int b[], int x_star[], int n) {
    int sign, d, i, j, k, k_c, k_r, pivot, t;

    sign = d = 1;
    for (k_c = k_r = 0; k_c < n; k_c++) {
      for (pivot = k_r; pivot < n && A[pivot][k_r] == 0; pivot++)
	;

      if (pivot < n) {
	if (pivot != k_r) {
	  for (j = k_c; j < n; j++) {
	    t = A[pivot][j];
	    A[pivot][j] = A[k_r][j];
	    A[k_r][j] = t;
	  }
	  t = b[pivot];
	  b[pivot] = b[k_r];
	  b[k_r] = t;

	  sign *= -1;
	}

	for (i = k_r+1; i < n; i++) {
	  for (j = k_c+1; j < n; j++) {
	    A[i][j] = (A[k_r][k_c]*A[i][j]-A[i][k_c]*A[k_r][j])/d;
	  }
	  b[i] = (A[k_r][k_c]*b[i]-A[i][k_c]*b[k_r])/d;
	  A[i][k_c] = 0;
	}
	if (d != 0) {
	  d = A[k_r][k_c];
	}
	k_r++;
      } else {
	d = 0;
      }
    }

    if (d == 0) {
      for (k = k_r; k < n; k++) {
	if (b[k] != 0) {
	  /* inconsistent system */
	  System.out.println("Inconsistent system.");
	  return 0;
	}
      }
      /* multiple solutions */
      System.out.println("More than one solution.");
      return 0;
    }

    for (k = n-1; k >= 0; k--) {
      x_star[k] = sign*d*b[k];
      for (j = k+1; j < n; j++) {
	x_star[k] -= A[k][j]*x_star[j];
      }
      x_star[k] /= A[k][k];
    }
    
    return sign*d;
  }

  static int gcd(int a, int b) {
    int r;
    if (a < 0) {
      a = -a;
    }
    if (b < 0) {
      b = -b;
    }
    while (b != 0) {
      r = a % b;
      a = b;
      b = r;
    }
    return a;
  }
      
  static void print_coeff(int a, int b) {
    int g = gcd(a, b);
    String str = new String("");

    if (g != 0) {
      a /= g;
      b /= g;
    }
    if (b == 1) {
      str = str + a;
    } else {
      str = str + a + "/" + b;
    }
    System.out.print(str);
  }

  static void print_poly(int x[], int start, int len, int d) {
    int i, c;
    boolean zero = true;

    for (i = 0; i < len; i++) {
      String str = new String("");
      c = x[start+i];
      if (c != 0) {
	if (!zero) {
	  str = str + " ";
	}
	str = str + "(";
	if (c < 0) {
	  str = str + "-";
	  c = -c;
	}
	System.out.print(str);
	print_coeff(c, d);
	System.out.print("," + i + ")");
	zero = false;
      }
    }
    
    if (zero) {
      System.out.print("(0,0)");
    }
    System.out.println("");
  }

  public static void main(String[] args) {
    int f[] = new int[MAX_N];
    int A[][] = new int[MAX_N][MAX_N];
    int x_star[] = new int[MAX_N];
    int b[] = new int[MAX_N];

    int m, n, i, j, det, case_no = 0;
    String line = new String("");
    StringTokenizer str;

    try {
      line = in.readLine();
    } catch (IOException e) {
    }
    str = new StringTokenizer(line);
    m = Integer.parseInt(str.nextToken());
    n = Integer.parseInt(str.nextToken());
    while (m != 0 || n != 0) {
      if (case_no++ > 0) {
	System.out.println("");
      }

      /* read f */
      for (i = 0; i < m+n; i++) {
	f[i] = Integer.parseInt(str.nextToken());
      }

      /* form system */
      for (i = 0; i < m+n; i++) {
	for (j = 0; j < m+n; j++) {
	  A[i][j] = 0;
	}
	b[i] = 0;
      }

      for (i = 0; i < m; i++) {
	A[i][n+i] = -1;
      }
      for (i = 0; i < m+n; i++) {
	for (j = 0; j <= i && j < n; j++) {
	  A[i][j] = f[i-j];
	}
      }
      b[m+n-1] = 1;

      det = fflinsolve(A, b, x_star, m+n);
      if (det < 0) {
	det = -det;
	for (i = 0; i < m+n; i++) {
	  x_star[i] = -x_star[i];
	}
      }
      print_poly(x_star, n, m, det);
      print_poly(x_star, 0, n, det);

      try {
	line = in.readLine();
      } catch (IOException e) {
      }
      str = new StringTokenizer(line);
      m = Integer.parseInt(str.nextToken());
      n = Integer.parseInt(str.nextToken());
    }
  }

}
