#include <bits/stdc++.h>
using namespace std;
const int MAX = 105;
int abs(int a) { return a > 0 ? a : -a; }
int a[MAX], b[MAX];
int gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = n; i >= 0; i--) {
      scanf("%d", &a[i]);
    }
    for (int i = m; i >= 0; i--) {
      scanf("%d", &b[i]);
    }
    int x, y;
    for (int i = 100; i >= 0; i--) {
      if (a[i] != 0) {
        x = i;
        break;
      }
    }
    for (int i = 100; i >= 0; i--) {
      if (b[i] != 0) {
        y = i;
        break;
      }
    }
    if (x > y) {
      if (a[x] * b[y] > 0)
        printf("Infinity\n");
      else
        printf("-Infinity\n");
    } else if (x == y) {
      int temp = gcd(abs(a[x]), abs(b[y]));
      if (a[x] * b[x] > 0)
        printf("%d/%d\n", abs(a[x]) / temp, abs(b[y]) / temp);
      else
        printf("-%d/%d\n", abs(a[x] / temp), abs(b[y] / temp));
    } else {
      printf("0/1\n");
    }
  }
}
