#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b != 0) {
    int t = b;
    b = a % b;
    a = t;
  }
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i, j, k, aa, bb, sign, g;
  cin >> n >> m;
  n++;
  m++;
  vector<int> a(n), b(m);
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < m; i++) cin >> b[i];
  if (n == m) {
    sign = 1;
    if (a[0] < 0) sign = -sign, a[0] = -a[0];
    if (b[0] < 0) sign = -sign, b[0] = -b[0];
    g = gcd(a[0], b[0]);
    aa = a[0] / g;
    bb = b[0] / g;
    if (sign == -1) cout << "-";
    cout << aa << "/" << bb << "\n";
  } else if (n < m)
    cout << "0/1\n";
  else {
    sign = 1;
    if (a[0] < 0) sign = -sign, a[0] = -a[0];
    if (b[0] < 0) sign = -sign, b[0] = -b[0];
    if (sign == -1) cout << "-";
    cout << "Infinity\n";
  }
  return 0;
}
