#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, temp;
  scanf(" %d %d", &n, &m);
  scanf(" %d", &a);
  int i;
  for (i = 0; i < n; ++i) scanf(" %d", &temp);
  scanf(" %d", &b);
  for (i = 0; i < m; ++i) scanf(" %d", &temp);
  int mdc, D, d, q, r;
  if (n == m) {
    D = max(a, b);
    d = min(a, b);
    mdc = d;
    q = D / d;
    r = D % d;
    while (r) {
      mdc = r;
      D = d;
      d = r;
      q = D / d;
      r = D % d;
    }
    a /= mdc;
    b /= mdc;
    if (b < 0) {
      b *= -1;
      a *= -1;
    }
    printf("%d/%d\n", a, b);
  } else if (n < m) {
    printf("0/1\n");
  } else {
    if ((a < 0) == (b < 0))
      printf("Infinity\n");
    else
      printf("-Infinity\n");
  }
  return 0;
}
