Problem p00688 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;
// kaewasuretyuui
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, pii> pip;
typedef vector<pip> vip;
const double PI = acos(-1);
const double EPS = 1e-5;
const int inf = 1e8;
int main() {
  int a, b, c;
  while (cin >> a >> b >> c, a || b || c) {
    for (int sa = 1; sa * sa <= a; sa++)
      if (a % sa == 0) {
        int la = a / sa;
        for (int sb = -10000; sb <= 10000; sb++) {
          if (sb && c % sb)
            continue;
          int lb = (sb ? c / sb : 0);
          rep(i, 2) {
            rep(j, 2) {
              if (sa * lb + la * sb == b) {
                if (la == sa && lb < sb)
                  swap(lb, sb);
                cout << la << " " << lb << " " << sa << " " << sb << endl;
                goto end;
              }
              sb *= -1;
              lb *= -1;
            }
            swap(sb, lb);
          }
        }
      }
    cout << "Impossible" << endl;
  end:;
  }
}

Error: -8

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;
// kaewasuretyuui
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, pii> pip;
typedef vector<pip> vip;
const double PI = acos(-1);
const double EPS = 1e-5;
const int inf = 1e8;
int main() {
  int a, b, c;
  while (cin >> a >> b >> c, a || b || c) {
    for (int sa = 1; sa * sa <= a; sa++)
      if (a % sa == 0) {
        int la = a / sa;
        for (int sb = -10000; sb <= 10000; sb++)
          if (c % sb == 0) {
            int lb = c / sb;
            rep(i, 2) {
              rep(j, 2) {
                if (sa * lb + la * sb == b) {
                  cout << la << " " << lb << " " << sa << " " << sb << endl;
                  goto end;
                }
                sb *= -1;
                lb *= -1;
              }
              swap(sb, lb);
            }
          }
      }
    cout << "Impossible" << endl;
  end:;
  }
}