#include <bits/stdc++.h>
using namespace std;
int grco(int a, int b) {
  int r;
  r = a % b;
  if (b == 0)
    return a;
  else
    return grco(b, r);
}
int main() {
  int i, j, k, l, m, n;
  cin >> n >> m;
  int a[n + 2], b[m + 2];
  n = n + 1;
  m = m + 1;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) cin >> b[i];
  i = 1;
  while (a[i] == 0) {
    i++;
    n--;
  }
  j = 1;
  while (b[j] == 0) {
    i++;
    m--;
  }
  if (n > m) {
    if ((a[i] < 0 && b[j] < 0) || (a[1] > 0 && b[1] > 0)) {
      cout << "Infinity" << endl;
      return 0;
    } else {
      cout << "-Infinity" << endl;
      return 0;
    }
  }
  if (n < m) {
    cout << "0/1" << endl;
    return 0;
  }
  if (n == m) {
    k = grco(a[i], b[j]);
    if ((a[i] < 0 && b[j] < 0) || (a[1] > 0 && b[1] > 0)) {
      cout << a[i] / k << '/' << b[j] / k << endl;
      return 0;
    } else {
      cout << '-' << abs(a[i] / k) << '/' << abs(b[j] / k) << endl;
      return 0;
    }
  }
}
