#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  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 (a[0] * b[0] < 0) {
      cout << "-Infinity\n";
    } else {
      cout << "Infinity\n";
    }
  } else if (m > n) {
    cout << "0/1\n";
  } else {
    int g = gcd(abs(a[0]), abs(b[0]));
    if (a[0] * b[0] > 0) {
      cout << abs(a[0]) / g << "/" << abs(b[0]) / g << "\n";
    } else {
      if (a[0] < 0) {
        cout << a[0] / g << "/" << b[0] / g << "\n";
      } else {
        cout << "-" << a[0] / g << "/" << -b[0] / g << "\n";
      }
    }
  }
  return 0;
}
