#include <bits/stdc++.h>
using namespace std;
inline int Abs(int a) { return (a > 0 ? a : -a); }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int GCD(int a, int b) {
  while (1) {
    a = a % b;
    if (a == 0) return b;
    b = b % a;
    if (b == 0) return a;
  }
}
vector<int> a, b;
int main() {
  int n, m;
  cin >> n >> m;
  a.resize(n + 1);
  b.resize(m + 1);
  for (int i = 0; i < (n + 1); ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < (m + 1); ++i) {
    cin >> b[i];
  }
  if (n > m) {
    if ((a[0] + 0.0) / b[0] > 0)
      cout << "Infinity" << endl;
    else
      cout << "-Infinity" << endl;
  } else if (m > n)
    cout << "0/1" << endl;
  else {
    if ((a[0] + 0.0) / b[0] < 0) cout << "-";
    int abs_a = Abs(a[0]);
    int abs_b = Abs(b[0]);
    int g = GCD(abs_a, abs_b);
    int res1 = abs_a / g;
    int res2 = abs_b / g;
    cout << res1 << "/" << res2 << endl;
  }
  return 0;
}
