#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  int i, z;
  while (y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return x;
}
int a[110];
int b[110];
int main() {
  int n, m, i, j, k, count = 0, s = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i <= n; i++) scanf("%d", &a[i]);
  for (i = 0; i <= m; i++) scanf("%d", &b[i]);
  for (i = 0; i < n; i++) {
    if (a[i] != 0) {
      n = n - i;
      break;
    }
  }
  for (j = 0; j < m; j++) {
    if (b[j] != 0) {
      m = m - j;
      break;
    }
  }
  if (a[i] < 0 && n != 0) count++;
  if (b[j] < 0 && m != 0) count++;
  for (k = i; k <= n; k++) {
    if (a[k] < 0 && k != n) a[k] = fabs(a[k]);
    if (a[k] < 0 && k == n) {
      a[k] = fabs(a[k]);
      s++;
    }
  }
  for (k = j; k <= m; k++) {
    if (b[k] < 0 && k != m) b[k] = fabs(b[k]);
    if (b[k] < 0 && k == m) {
      b[k] = fabs(b[k]);
      s++;
    }
  }
  if (m > n) {
    printf("0/1\n");
    return 0;
  }
  if (count % 2 == 1) printf("-");
  if (n > m)
    printf("Infinity\n");
  else if (n == m && n != 0 && b[j] % a[i] == 0)
    printf("1/%d\n", b[j] / a[i]);
  else if (n == m && n != 0)
    printf("%d/%d\n", a[i] / gcd(a[i], b[j]), b[j] / gcd(a[i], b[j]));
  else if (n == 0 && m == 0 && s % 2 == 0)
    printf("%d/%d\n", a[n] / gcd(a[n], b[m]), b[m] / gcd(a[n], b[m]));
  else if (n == 0 && m == 0 && s % 2 == 1)
    printf("-%d/%d\n", a[n] / gcd(a[n], b[m]), b[m] / gcd(a[n], b[m]));
  return 0;
}
