#include <bits/stdc++.h>
using namespace std;

int x, y, z;

int segs[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int getCurrent(int number) {
  int current = 0;
  if (number == 0) {
    return 30;
  }
  if (number < 0) {
    current++;
    number = -number;
  }

  while (number) {
    current += segs[number % 10];
    number /= 10;
  }
  return current * 5;
}

int main() {
  while (cin >> x && x) {
    cin >> y >> z;
    int solutions = 0;
    for (int i = -999; i < 1000; i++) {
      for (int j = -999; j < 1000; j++) {
        int xx = getCurrent(i);
        int yy = getCurrent(j);

        if (x == xx && y == yy && z == getCurrent(i + j) && i + j >= -999 && i + j < 1000) {
          solutions++;
        }

        if (x == xx && y == yy && z == getCurrent(i - j) && i - j >= -999 && i - j < 1000) {
          solutions++;
        }

        if (x == xx && y == yy && z == getCurrent(i * j) && i * j >= -999 && i * j < 1000) {
          solutions++;
        }

        if (x == xx && y == yy && j && z == getCurrent(i / j) && i / j >= -999 && i / j < 1000) {
          solutions++;
        }
      }
    }
    cout << solutions << " solution" << ((solutions == 1) ? ("") : ("s")) << " for " 
     << x << ' ' << y << ' ' << z <<  '\n';
  }

  return 0;
}