#include <bits/stdc++.h>
using namespace std;
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n, m;
  cin >> n >> m;
  int nn[n + 1];
  for (int i = 0; i <= n; i++) cin >> nn[i];
  int mm[m + 1];
  for (int i = 0; i <= m; i++) cin >> mm[i];
  if (n > m) {
    cout << (nn[0] * mm[0] < 0 ? "-Infinity\n" : "Infinity\n");
  } else if (n < m) {
    cout << "0/1\n";
  } else {
    int a = nn[0];
    int b = mm[0];
    int gcdab = gcd(abs(a), abs(b));
    a /= gcdab;
    b /= gcdab;
    if (a * b < 0)
      cout << "-" << abs(a) << "/" << abs(b) << '\n';
    else
      cout << abs(a) << "/" << abs(b) << '\n';
  }
  return 0;
}
