#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int main() {
  int n, m, an[120], am[120], fa = -1, fb = -1, f = 0, a, b;
  cin >> n >> m;
  for (int i = 0; i < n + 1; i++) {
    cin >> an[i];
    if (f == 0 && an[i] != 0) {
      f = 1;
      fa = n - i;
    }
  }
  f = 0;
  for (int i = 0; i < m + 1; i++) {
    cin >> am[i];
    if (f == 0 && am[i] != 0) {
      f = 1;
      fb = m - i;
    }
  }
  a = an[n - fa];
  b = am[m - fb];
  if (fa < 0 && fb < 0) {
    cout << "0/1" << endl;
  }
  if (fb == fa) {
    f = gcd(a, b);
    a /= f;
    b /= f;
    if (b < 0) {
      b = abs(b);
      a *= -1;
    }
    cout << a << "/" << b << endl;
  }
  if (fa > fb) {
    if (a * b > 0)
      cout << "Infinity" << endl;
    else
      cout << "-Infinity" << endl;
  } else if (fa < fb) {
    cout << "0/1" << endl;
  }
  return 0;
}
