#include <bits/stdc++.h>
using namespace std;
int a[111], b[111], n, m;
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    n += 1;
    m += 1;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < m; i++) scanf("%d", &b[i]);
    int posa, posb;
    for (posa = 0; a[posa] == 0 && posa < n; posa++)
      ;
    for (posb = 0; b[posb] == 0 && posb < m; posb++)
      ;
    int ans;
    if (n - posa < m - posb) {
      printf("0/1\n");
      continue;
    }
    if (n - posa > m - posb) {
      if (a[posa] * b[posb] > 0)
        printf("Infinity\n");
      else
        printf("-Infinity\n");
      continue;
    }
    int flag;
    if (a[posa] * b[posb] > 0)
      flag = 0;
    else
      flag = 1;
    a[posa] = fabs(a[posa]);
    b[posb] = fabs(b[posb]);
    int xx = gcd(a[posa], b[posb]);
    a[posa] /= xx;
    b[posb] /= xx;
    if (flag) printf("-");
    printf("%d/%d\n", a[posa], b[posb]);
  }
  return 0;
}
