using System;
public class Test
{
public static void Main()
{
int N = 10;
double p = 0.3 * N, t = 0.2 * N;
int count = 0;
double[,] A, B;
A= new double[,]{
{12.5,1.4,1.1+p,0.7,-7+t},
{1.2,10,1.5,1.7+p,6-0.2*t},
{1.1,2.5-p,11.2,1.3,10.3},
{0.7,2,3.1,15,-5-t}};
B = new double[4, 5];
double[] x, b;
x = new double[4];
b = new double[4] { 0, 0, 0, 0 };
Console.WriteLine("Startup matrix:");
for (int i = 0; i < 4; i++)
for (int j = 0; j < 5; j++)
{
Console.Write(A[i, j] + "\t");
count++;
if (count == 4) Console.Write("=");
if (count == 5){Console.Write("\n");count = 0;}
} //вывести на экран наш массив
Console.WriteLine();
double[,] IterationA, IterationB;
IterationA = new double[4, 5];
IterationB = new double[4, 5];
int IterationNum = 0, Iteration = 1;
double alfa, epsilon =-1;
double iter, check=0; //||x(k+1)-x(k)||
Console.WriteLine("Iteration #" + Iteration);
for (int i = 0; i < 4; i++) //ищем х1,2,3,4
for (int j = 0; j < 5; j++)
{
if (Iteration == 1) B[i, j] = A[i, j]; //Первое получение значений массива А
if (i == j) B[i, j] = 0;
else
{
if (j < 3) B[i, j] = -B[i, j] / A[i, i]; //x[1..3]=-b[i]/a[i]
else B[i, j] = B[i, j] / A[i, i]; //x[4](beta)=b[i]/a[i,i]
}
Console.Write(Math.Round(B[i, j], 4) + "\t");
count++;
if (count == 4) Console.Write("=");
if (count == 5) { Console.Write("\n"); count = 0; }
} //массив B
for (int i = 0; i < 4; i++) b[i] = B[i, 4]; //beta(1,2,3,4)
for (int i = 0; i < 4; i++)
for (int j = 0; j < 5; j++)
{
if (j < 4) x[i] += B[i, j] * b[i];
else x[i] += B[i, j];
} Console.WriteLine(); //значения x
//alfa (делается 1 раз)
double[] elem = new double[4]; //значения при х(k)
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
{
elem[i] += B[i, j];
}
alfa = elem[0]; //||a||
for (int i = 1; i < 4; i++)
if (Math.Abs(elem[i]) > alfa) alfa = Math.Abs(elem[i]);
Console.WriteLine("a=" + alfa);
//
if (Iteration%2!=0)
{
IterationA = B;
IterationNum = 1;
}
else
{
IterationB = B;
IterationNum = 0;
}
//первая итерация
while (check > epsilon)
{
epsilon = 0.0001;
Iteration++;
if (Iteration>11)
{
Console.WriteLine("TOO MUCH ITERATIONS");
break;
}
Console.WriteLine("Iteration #" + Iteration);
for (int i = 0; i < 4; i++) //ищем х1,2,3,4
for (int j = 0; j < 5; j++)
{
if (Iteration == 1) B[i, j] = A[i, j]; //Первое получение значений массива А
if (i == j) B[i, j] = 0;
else{
if (j < 3) B[i, j] = -B[i, j] / A[i, i]; //x[1..3]=-b[i]/a[i]
else B[i, j] = B[i, j] / A[i, i]; //x[4](beta)=b[i]/a[i,i]
}
Console.Write(Math.Round(B[i, j], 4) + "\t");
count++;
if (count == 4) Console.Write("=");
if (count == 5){Console.Write("\n"); count = 0;}
} //массив B
for (int i = 0; i < 4; i++) b[i] = B[i, 4]; //beta(1,2,3,4)
for (int i = 0; i < 4; i++)
for (int j = 0; j < 5; j++){
if (j < 4) x[i] += B[i, j] * b[i];
else x[i] += B[i, j];
} Console.WriteLine(); //значения x
Console.WriteLine("Критичне місце");
if (Iteration%2!=0){
Console.WriteLine("Гілка A");
IterationA = B;
IterationNum = 1;
}
else{
Console.WriteLine("Гілка B");
IterationB = B;
IterationNum = 0;
}
if (Iteration > 1)
{
double[] elem0 = new double[4]; //значения при х(k)
double[] elem1 = new double[4]; //значения при х(k+1)
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
{
elem0[i] += IterationA[i, j];
elem1[i] += IterationB[i, j];
}
for (int i = 0; i < 4; i++)
for (int j = 0; j < 5; j++)
{
Console.Write(IterationA[i, j] + "\t");
count++;
if (count == 4) Console.Write("=");
if (count == 5) { Console.Write("\n"); count = 0; }
} //вывести на экран наш массив IterationA
for (int i = 0; i < 4; i++)
for (int j = 0; j < 5; j++)
{
Console.Write(IterationB[i, j] + "\t");
count++;
if (count == 4) Console.Write("=");
if (count == 5) { Console.Write("\n"); count = 0; }
} //вывести на экран наш массив IterationB
iter = -10;
for (int i = 0; i < 4; i++)
if (Math.Abs(elem1[i] - elem0[i]) > iter)
iter = Math.Abs(elem1[i] - elem0[i]);
//
check = iter;
Console.WriteLine("alfa = {0},\n||x(k+1)-x(k)|| = {1}", alfa, iter);
}
for (int i = 0; i < 4; i++)
Console.WriteLine("x[{0}] = {1}", i + 1, x[i]);
Console.WriteLine();
}
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCWludCBOID0gMTA7CiAgICAgICAgICAgIGRvdWJsZSBwID0gMC4zICogTiwgdCA9IDAuMiAqIE47CiAgICAgICAgICAgIGludCBjb3VudCA9IDA7CiAgICAgICAgICAgIGRvdWJsZVssXSBBLCBCOwogICAgICAgICAgICBBPSBuZXcgZG91YmxlWyxdewogICAgICAgICAgICAgICAgezEyLjUsMS40LDEuMStwLDAuNywtNyt0fSwgCiAgICAgICAgICAgICAgICB7MS4yLDEwLDEuNSwxLjcrcCw2LTAuMip0fSwgCiAgICAgICAgICAgICAgICB7MS4xLDIuNS1wLDExLjIsMS4zLDEwLjN9LAogICAgICAgICAgICAgICAgezAuNywyLDMuMSwxNSwtNS10fX07CiAgICAgICAgICAgIEIgPSBuZXcgZG91YmxlWzQsIDVdOwogICAgICAgICAgICBkb3VibGVbXSB4LCBiOwogICAgICAgICAgICB4ID0gbmV3IGRvdWJsZVs0XTsKICAgICAgICAgICAgYiA9IG5ldyBkb3VibGVbNF0geyAwLCAwLCAwLCAwIH07CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJTdGFydHVwIG1hdHJpeDoiKTsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCA0OyBpKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDU7IGorKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlKEFbaSwgal0gKyAiXHQiKTsKICAgICAgICAgICAgICAgICAgICBjb3VudCsrOwogICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA9PSA0KSBDb25zb2xlLldyaXRlKCI9Iik7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvdW50ID09IDUpe0NvbnNvbGUuV3JpdGUoIlxuIik7Y291bnQgPSAwO30KICAgICAgICAgICAgICAgIH0gICAvL9Cy0YvQstC10YHRgtC4INC90LAg0Y3QutGA0LDQvSDQvdCw0Ygg0LzQsNGB0YHQuNCyCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCk7CiAgICAgICAgICAgIGRvdWJsZVssXSBJdGVyYXRpb25BLCBJdGVyYXRpb25COwogICAgICAgICAgICBJdGVyYXRpb25BID0gbmV3IGRvdWJsZVs0LCA1XTsKICAgICAgICAgICAgSXRlcmF0aW9uQiA9IG5ldyBkb3VibGVbNCwgNV07CiAgICAgICAgICAgIGludCBJdGVyYXRpb25OdW0gPSAwLCBJdGVyYXRpb24gPSAxOwogICAgICAgICAgICBkb3VibGUgYWxmYSwgZXBzaWxvbiA9LTE7CiAgICAgICAgICAgIGRvdWJsZSBpdGVyLCBjaGVjaz0wOyAgICAvL3x8eChrKzEpLXgoayl8fAogICAgICAgICAgICAKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkl0ZXJhdGlvbiAjIiArIEl0ZXJhdGlvbik7CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKSAgLy/QuNGJ0LXQvCDRhTEsMiwzLDQKICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgNTsgaisrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmIChJdGVyYXRpb24gPT0gMSkgQltpLCBqXSA9IEFbaSwgal07IC8v0J/QtdGA0LLQvtC1INC/0L7Qu9GD0YfQtdC90LjQtSDQt9C90LDRh9C10L3QuNC5INC80LDRgdGB0LjQstCwINCQCiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT0gaikgQltpLCBqXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGogPCAzKSBCW2ksIGpdID0gLUJbaSwgal0gLyBBW2ksIGldOyAgICAgICAgLy94WzEuLjNdPS1iW2ldL2FbaV0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBCW2ksIGpdID0gQltpLCBqXSAvIEFbaSwgaV07ICAgICAgICAgICAgICAgLy94WzRdKGJldGEpPWJbaV0vYVtpLGldIAogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlKE1hdGguUm91bmQoQltpLCBqXSwgNCkgKyAiXHQiKTsKICAgICAgICAgICAgICAgICAgICBjb3VudCsrOwogICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA9PSA0KSBDb25zb2xlLldyaXRlKCI9Iik7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvdW50ID09IDUpIHsgQ29uc29sZS5Xcml0ZSgiXG4iKTsgY291bnQgPSAwOyB9CiAgICAgICAgICAgICAgICB9IC8v0LzQsNGB0YHQuNCyIEIKCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKSBiW2ldID0gQltpLCA0XTsgIC8vYmV0YSgxLDIsMyw0KQoKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCA0OyBpKyspCiAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDU7IGorKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaiA8IDQpIHhbaV0gKz0gQltpLCBqXSAqIGJbaV07CiAgICAgICAgICAgICAgICAgICAgZWxzZSB4W2ldICs9IEJbaSwgal07CiAgICAgICAgICAgICAgICB9IENvbnNvbGUuV3JpdGVMaW5lKCk7IC8v0LfQvdCw0YfQtdC90LjRjyB4CgogICAgICAgICAgICAvL2FsZmEgKNC00LXQu9Cw0LXRgtGB0Y8gMSDRgNCw0LcpCiAgICAgICAgICAgIGRvdWJsZVtdIGVsZW0gPSBuZXcgZG91YmxlWzRdOyAvL9C30L3QsNGH0LXQvdC40Y8g0L/RgNC4INGFKGspCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKQogICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCA0OyBqKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZWxlbVtpXSArPSBCW2ksIGpdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICBhbGZhID0gZWxlbVswXTsgIC8vfHxhfHwKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPCA0OyBpKyspCiAgICAgICAgICAgICAgICBpZiAoTWF0aC5BYnMoZWxlbVtpXSkgPiBhbGZhKSBhbGZhID0gTWF0aC5BYnMoZWxlbVtpXSk7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJhPSIgKyBhbGZhKTsKICAgICAgICAgICAgLy8KCgogICAgICAgICAgICBpZiAoSXRlcmF0aW9uJTIhPTApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIEl0ZXJhdGlvbkEgPSBCOwogICAgICAgICAgICAgICAgSXRlcmF0aW9uTnVtID0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIEl0ZXJhdGlvbkIgPSBCOwogICAgICAgICAgICAgICAgSXRlcmF0aW9uTnVtID0gMDsKICAgICAgICAgICAgfQovL9C/0LXRgNCy0LDRjyDQuNGC0LXRgNCw0YbQuNGPCgogICAgICAgICAgICB3aGlsZSAoY2hlY2sgPiBlcHNpbG9uKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBlcHNpbG9uID0gMC4wMDAxOwogICAgICAgICAgICAgICAgSXRlcmF0aW9uKys7CiAgICAgICAgICAgICAgICBpZiAoSXRlcmF0aW9uPjExKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJUT08gTVVDSCBJVEVSQVRJT05TIik7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiSXRlcmF0aW9uICMiICsgSXRlcmF0aW9uKTsKCiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDQ7IGkrKykgIC8v0LjRidC10Lwg0YUxLDIsMyw0CiAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCA1OyBqKyspCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoSXRlcmF0aW9uID09IDEpIEJbaSwgal0gPSBBW2ksIGpdOyAvL9Cf0LXRgNCy0L7QtSDQv9C+0LvRg9GH0LXQvdC40LUg0LfQvdCw0YfQtdC90LjQuSDQvNCw0YHRgdC40LLQsCDQkAogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PSBqKSBCW2ksIGpdID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZXsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChqIDwgMykgQltpLCBqXSA9IC1CW2ksIGpdIC8gQVtpLCBpXTsgICAgICAgIC8veFsxLi4zXT0tYltpXS9hW2ldCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIEJbaSwgal0gPSBCW2ksIGpdIC8gQVtpLCBpXTsgICAgICAgICAgICAgICAvL3hbNF0oYmV0YSk9YltpXS9hW2ksaV0gCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZShNYXRoLlJvdW5kKEJbaSwgal0sIDQpICsgIlx0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50Kys7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA9PSA0KSBDb25zb2xlLldyaXRlKCI9Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA9PSA1KXtDb25zb2xlLldyaXRlKCJcbiIpOyBjb3VudCA9IDA7fQogICAgICAgICAgICAgICAgICAgIH0gLy/QvNCw0YHRgdC40LIgQgoKICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKSBiW2ldID0gQltpLCA0XTsgIC8vYmV0YSgxLDIsMyw0KQoKICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKQogICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgNTsgaisrKXsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGogPCA0KSB4W2ldICs9IEJbaSwgal0gKiBiW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHhbaV0gKz0gQltpLCBqXTsKICAgICAgICAgICAgICAgICAgICB9IENvbnNvbGUuV3JpdGVMaW5lKCk7IC8v0LfQvdCw0YfQtdC90LjRjyB4CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoItCa0YDQuNGC0LjRh9C90LUg0LzRltGB0YbQtSIpOwogICAgICAgICAgICAgICAgaWYgKEl0ZXJhdGlvbiUyIT0wKXsKICAgICAgICAgICAgICAgIAlDb25zb2xlLldyaXRlTGluZSgi0JPRltC70LrQsCBBIik7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0aW9uQSA9IEI7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0aW9uTnVtID0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2V7CiAgICAgICAgICAgICAgICAJQ29uc29sZS5Xcml0ZUxpbmUoItCT0ZbQu9C60LAgQiIpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdGlvbkIgPSBCOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdGlvbk51bSA9IDA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAKCiAgICAgICAgICAgICAgICBpZiAoSXRlcmF0aW9uID4gMSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBkb3VibGVbXSBlbGVtMCA9IG5ldyBkb3VibGVbNF07IC8v0LfQvdCw0YfQtdC90LjRjyDQv9GA0Lgg0YUoaykKICAgICAgICAgICAgICAgICAgICBkb3VibGVbXSBlbGVtMSA9IG5ldyBkb3VibGVbNF07IC8v0LfQvdCw0YfQtdC90LjRjyDQv9GA0Lgg0YUoaysxKQogICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDQ7IGorKykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbTBbaV0gKz0gSXRlcmF0aW9uQVtpLCBqXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW0xW2ldICs9IEl0ZXJhdGlvbkJbaSwgal07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDQ7IGkrKykKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCA1OyBqKyspCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGUoSXRlcmF0aW9uQVtpLCBqXSArICJcdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY291bnQrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA9PSA0KSBDb25zb2xlLldyaXRlKCI9Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY291bnQgPT0gNSkgeyBDb25zb2xlLldyaXRlKCJcbiIpOyBjb3VudCA9IDA7IH0KICAgICAgICAgICAgICAgICAgICAgICAgfSAgIC8v0LLRi9Cy0LXRgdGC0Lgg0L3QsCDRjdC60YDQsNC9INC90LDRiCDQvNCw0YHRgdC40LIgSXRlcmF0aW9uQQogICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDU7IGorKykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZShJdGVyYXRpb25CW2ksIGpdICsgIlx0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3VudCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvdW50ID09IDQpIENvbnNvbGUuV3JpdGUoIj0iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA9PSA1KSB7IENvbnNvbGUuV3JpdGUoIlxuIik7IGNvdW50ID0gMDsgfQogICAgICAgICAgICAgICAgICAgICAgICB9ICAgLy/QstGL0LLQtdGB0YLQuCDQvdCwINGN0LrRgNCw0L0g0L3QsNGIINC80LDRgdGB0LjQsiBJdGVyYXRpb25CCiAgICAgICAgICAgICAgICAgICAgaXRlciA9IC0xMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDQ7IGkrKykKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguQWJzKGVsZW0xW2ldIC0gZWxlbTBbaV0pID4gaXRlcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXIgPSBNYXRoLkFicyhlbGVtMVtpXSAtIGVsZW0wW2ldKTsKICAgICAgICAgICAgICAgICAgICAvLwogICAgICAgICAgICAgICAgICAgIGNoZWNrID0gaXRlcjsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiYWxmYSA9IHswfSxcbnx8eChrKzEpLXgoayl8fCA9IHsxfSIsIGFsZmEsIGl0ZXIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCA0OyBpKyspCiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoInhbezB9XSA9IHsxfSIsIGkgKyAxLCB4W2ldKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCk7CiAgICAgICAgICAgIH0KCgl9Cn0=