#include <bits/stdc++.h>
using namespace std;
int n, m;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  cin >> n >> m;
  int tmp;
  int d1 = 0, p1 = 0, d2 = 0, p2 = 0;
  for (int i = 0; i < n + 1; ++i) {
    cin >> tmp;
    if (tmp && !d1) {
      p1 = tmp;
      d1 = n - i;
    }
  }
  for (int i = 0; i < m + 1; ++i) {
    cin >> tmp;
    if (tmp && !d2) {
      p2 = tmp;
      d2 = m - i;
    }
  }
  int g = abs(gcd(p1, p2));
  if (g != 0) {
    p1 /= g;
    p2 /= g;
  }
  if (d1 > d2) {
    if ((p1 >= 0 && p2 >= 0) || (p1 < 0 && p2 < 0))
      cout << "Infinity" << endl;
    else
      cout << "-Infinity" << endl;
  } else if (d1 < d2) {
    cout << "0/1" << endl;
  } else {
    if (p2 >= 0)
      cout << p1 << "/" << p2 << endl;
    else
      cout << -1 * p1 << "/" << -1 * p2 << endl;
  }
  return 0;
}
