#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  gcd(b, a % b);
}
int n, m, a, b, t;
bool eo = 0;
int main() {
  cin >> n >> m;
  n++;
  m++;
  for (int i = 1; i <= n; i++) {
    if (i == 1)
      cin >> a;
    else
      cin >> t;
  }
  for (int i = 1; i <= m; i++) {
    if (i == 1)
      cin >> b;
    else
      cin >> t;
  }
  if (a * b < 0) eo = 1;
  if (n > m) {
    if (eo) cout << '-';
    cout << "Infinity" << endl;
  }
  if (n < m) {
    cout << "0/1";
  }
  if (n == m) {
    a = abs(a), b = abs(b);
    int t = gcd(a, b);
    if (eo) cout << '-';
    a /= t, b /= t;
    cout << a << "/" << b;
  }
}
