object Main {
  def main(args: Array[String]): Unit = {
    val Array(a, b) = io.StdIn.readLine().split(" ").map(_.toInt)
    println(extendedEuclidean(a, b))
  }
  def extendedEuclidean(a: Int, b: Int): (Int, Int) = {
    def loop(pr: Int, r: Int, ps: Int, s: Int, pt: Int, t: Int): (Int, Int) =
      if (r == 0) (ps, pt)
      else {
        val q = pr / r
        loop(r, pr-q*r, s, ps-q*s, t, pt-q*t)
      }
    loop(a, b, 1, 0, 0, 1)
  }
}