#include <bits/stdc++.h>
using namespace std;
const int maxn = (1e5) + 10;
const int mod = (1e9) + 7;
const int inf = (1e9) + 10;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v1, v2;
  for (int i = 0; i <= n; i++) {
    int x;
    cin >> x;
    v1.push_back(x);
  }
  for (int i = 0; i <= m; i++) {
    int x;
    cin >> x;
    v2.push_back(x);
  }
  if (n > m) {
    if (v1[0] * v2[0] > 0)
      return cout << "Infinity", 0;
    else
      return cout << "-Infinity", 0;
  } else if (m > n)
    return cout << "0/1", 0;
  else {
    for (int i = 2; i <= min(abs(v1[0]), abs(v2[0])); i++) {
      while (v1[0] % i == 0 && v2[0] % i == 0) {
        v1[0] /= i;
        v2[0] /= i;
      }
    }
    if (v1[0] * v2[0] > 0)
      return cout << abs(v1[0]) << '/' << abs(v2[0]), 0;
    else
      return cout << '-' << abs(v1[0]) << '/' << abs(v2[0]), 0;
  }
  return 0;
}
