using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("1 2");
WillReturn.Add("2 1");
WillReturn.Add("12 14 8 2");
//6 4 2
}
else if (InputPattern == "Input2") {
WillReturn.Add("1 1");
WillReturn.Add("100 1");
WillReturn.Add("10000 0 -1");
//100 -1
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
var AList = InputList[1].Split(' ').Select(pX => int.Parse(pX)).ToList();
var CList = InputList[2].Split(' ').Select(pX => int.Parse(pX)).ToList();
var AnswerDict = new Dictionary<int, int>();
while (true) {
// Aのほうが次数が多かったら終了
int JisuuA = GetJisuu(AList);
int JisuuC = GetJisuu(CList);
if (JisuuA > JisuuC) break;
int JisuuDiff = JisuuC - JisuuA;
int CurrAnswer = CList.Last() / AList.Last();
AnswerDict[JisuuDiff] = CurrAnswer;
for (int I = 0; I <= AList.Count - 1; I++) {
CList[I + JisuuDiff] -= AList[I] * CurrAnswer;
}
}
var AnswerList = new List<int>();
foreach (var EachPair in AnswerDict.OrderBy(pX => pX.Key)) {
AnswerList.Add(EachPair.Value);
}
Console.WriteLine(IntEnumJoin(" ", AnswerList));
}
// 定数項でない最上位項が0だったらRemoveしつつ、次数を返す
static int GetJisuu(List<int> pList)
{
while (true) {
int UB = pList.Count - 1;
if (UB > 0 && pList[UB] == 0) {
pList.RemoveAt(UB);
}
break;
}
return pList.Count;
}
////////////////////////////////////////////////////////////////
// セパレータとInt型の列挙を引数として、結合したstringを返す
////////////////////////////////////////////////////////////////
static string IntEnumJoin(string pSeparater, IEnumerable<int> pEnum)
{
string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString());
return string.Join(pSeparater, StrArr);
}
}