#include <bits/stdc++.h>
const int nax = 1e5 + 5;
using namespace std;
int gcd(int x, int y) {
  if (x % y == 0) return y;
  return gcd(y, x % y);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1), b(m + 1);
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= m; i++) {
    cin >> b[i];
  }
  if (n != m) {
    if (n > m) {
      if ((a[0] > 0 && b[0] > 0) || (a[0] < 0 && b[0] < 0)) {
        puts("Infinity");
      } else {
        puts("-Infinity");
      }
    } else {
      cout << "0/1"
           << "\n";
    }
    return 0;
  } else {
    int ans = gcd(a[0], b[0]);
    if ((a[0] > 0 && b[0] > 0) || (a[0] < 0 && b[0] < 0))
      cout << a[0] / ans << "/" << b[0] / ans << "\n";
    else
      cout << -abs(a[0] / ans) << "/" << abs(b[0] / ans) << "\n";
  }
  return 0;
}
