#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main(void) {
  int n, m;
  vector<int> first, second;
  cin >> n >> m;
  int temp;
  int nn = ++n, mm = ++m;
  while (nn--) {
    cin >> temp;
    first.push_back(temp);
  }
  while (mm--) {
    cin >> temp;
    second.push_back(temp);
  }
  for (vector<int>::iterator i = first.begin(); i != first.end();) {
    if (*i == 0) {
      --n;
      first.erase(i);
    } else
      break;
  }
  for (vector<int>::iterator i = second.begin(); i != second.end();) {
    if (*i == 0) {
      --m;
      second.erase(i);
    } else
      break;
  }
  if (m == n) {
    int a1 = first.front();
    int a2 = second.front();
    if (a1 * a2 < 0) {
      cout << '-';
    }
    if (a1 < 0) a1 = 0 - a1;
    if (a2 < 0) a2 = 0 - a2;
    int gc;
    if (a1 > a2)
      gc = gcd(a1, a2);
    else
      gc = gcd(a2, a1);
    cout << a1 / gc << '/' << a2 / gc << endl;
  } else if (m > n) {
    cout << "0/1" << endl;
  } else if (m < n) {
    if (first.front() * second.front() < 0) {
      cout << '-';
    }
    cout << "Infinity" << endl;
  }
  return 0;
}
