#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, k, i;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d", &a);
  for (i = 0; i < n; i++) scanf("%d", &c);
  scanf("%d", &b);
  for (i = 0; i < m; i++) scanf("%d", &c);
  k = a * b;
  if (n > m) {
    if (k < 0) printf("-");
    printf("Infinity\n");
  } else if (n < m) {
    printf("0/1\n");
  } else {
    if (k < 0) printf("-");
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    c = gcd(a, b);
    a /= c;
    b /= c;
    printf("%d/%d\n", a, b);
  }
  return 0;
}
