import std.stdio, std.string;
import std.container.rbtree;

void solve(int[] a, int k)
{
    auto n = cast(int)a.length;
    auto rbt = redBlackTree!int();
    int[int] cnt;
    foreach (i; 0 .. n)
    {
        if (i >= k && a[i - k] != a[i])
        {
            -- cnt[a[i - k]];
            if (cnt[a[i - k]] == 1)
            {
                rbt.insert(a[i - k]);
            }
            else
            {
                rbt.removeKey(a[i - k]);
            }
        }
        if (i < k || a[i - k] != a[i])
        {
            if (!(a[i] in cnt))
            {
                cnt[a[i]] = 0;
            }
            ++ cnt[a[i]];
            if (cnt[a[i]] == 1)
            {
                rbt.insert(a[i]);
            }
            else
            {
                rbt.removeKey(a[i]);
            }
        }
        if (i >= k - 1)
        {
            if (rbt.length > 0)
            {
                writeln(rbt.back());
            }
            else
            {
                writeln("Nothing");
            }
        }
    }
}

int main(string[] args)
{
    int n, k;
    while (readf("%d %d\n", &n, &k) == 2)
    {
        auto a = new int[n];
        foreach (i; 0 .. n)
        {
            readf("%d\n", &a[i]);
        }
        solve(a, k);
    }
    return 0;
}

import std.stdio, std.string;
import std.random;

class Treap(T)
{
    class Node
    {
        Node left;
        Node right;
        T val;
        int priority;

        this()
        {
            left = right = null;
        }

        //int opCmp(Node node)
        //{
            //return this.priority - node.priority;
        //}

        int cmpPriority(int priority)
        {
            if (this.priority == priority) return 0;
            return this.priority < priority ? -1 : 1;
        }

        int cmpVal(T val)
        {
            if (this.val == val) return 0;
            return this.val < val ? -1 : 1;
        }
    }

    protected Node root;
    protected Xorshift rnd;
    protected int size;
    protected T minimal;
    protected T maximal;

    this()
    {
        root = null;
        rnd = Xorshift(1234567891);
        size = 0;
        minimal = T.max;
        maximal = T.min;
    }

    protected void leftRotate(ref Node node)
    {
        if (!node.right) return;
        auto rightNode = node.right;
        if (rightNode)
        {
            node.right = rightNode.left;
            rightNode.left = node;
            node = rightNode;
        }
    }

    protected void rightRotate(ref Node node)
    {
        if (!node.left) return;
        auto leftNode = node.left;
        if (leftNode)
        {
            node.left = leftNode.right;
            leftNode.right = node;
            node = leftNode;
        }
    }

    protected Node find(T val)
    {
        return _find(root, val);
    }

    protected Node _find(Node node, T val)
    {
        if (!node) return null;
        auto ret = node.cmpVal(val);
        if (ret == 0) return node;
        if (ret == -1) return _find(node.right, val);
        return _find(node.left, val);
    }

    public void insert(T val)
    {
        _insert(root, val);
    }

    protected void _insert(ref Node node, T val)
    {
        if (!node)
        {
            node = new Node();
            node.val = val;
            node.priority = this.rnd.front;
            this.rnd.seed(unpredictableSeed);
            ++ size;
            return;
        }
        auto ret = node.cmpVal(val);
        if (ret == 0) return;
        if (ret == 1)
        {
            _insert(node.left, val);
            if (node.left.priority > node.priority)
            {
                rightRotate(node);
            }
        }
        else if (ret == -1)
        {
            _insert(node.right, val);
            if (node.right.priority > node.priority)
            {
                leftRotate(node);
            }
        }
    }

    public void remove(T val)
    {
        _remove(root, val);
    }

    protected void _remove(ref Node node, T val)
    {
        if (!node) return;
        auto ret = node.cmpVal(val);
        if (ret == 0)
        {
            if (!node.left && !node.right)
            {
                node = null;
                -- size;
                return;
            }
            if (!node.left)
            {
                node = node.right;
                -- size;
                return;
            }
            if (!node.right)
            {
                node = node.left;
                -- size;
                return;
            }
            if (node.left.cmpPriority(node.right.priority) == 1)
            {
                rightRotate(node);
                _remove(node.right, val);
            }
            else
            {
                leftRotate(node);
                _remove(node.left, val);
            }
            return;
        }
        if (ret == -1)
        {
            _remove(node.right, val);
        }
        else
        {
            _remove(node.left, val);
        }
    }

    protected T _getMinimal(Node node)
    {
        if (!node) return minimal;
        if (!node.left) return node.val;
        return _getMinimal(node.left);
    }

    public T getMinimal()
    {
        return _getMinimal(root);
    }

    protected T _getMaximal(Node node)
    {
        if (!node) return maximal;
        if (!node.right) return node.val;
        return _getMaximal(node.right);
    }

    public T getMaximal()
    {
        return _getMaximal(root);
    }

    public void travel()
    {
        _travel(root);
    }

    protected void _travel(Node node)
    {
        if (!node) return;
        _travel(node.left);
        writeln(node.val);
        writeln(node.priority);
        _travel(node.right);
    }

    public void clear()
    {
        while (root)
        {
            remove(root.val);
        }
    }
}

void solve(int[] a, int k)
{
    auto n = cast(int)a.length;
    auto treap = new Treap!int();
    int[int] cnt;
    foreach (i; 0 .. n)
    {
        if (i >= k && a[i - k] != a[i])
        {
            -- cnt[a[i - k]];
            if (cnt[a[i - k]] == 1)
            {
                treap.insert(a[i - k]);
            }
            else
            {
                treap.remove(a[i - k]);
            }
        }
        if (i < k || a[i - k] != a[i])
        {
            if (!(a[i] in cnt))
            {
                cnt[a[i]] = 0;
            }
            ++ cnt[a[i]];
            if (cnt[a[i]] == 1)
            {
                treap.insert(a[i]);
            }
            else
            {
                treap.remove(a[i]);
            }
        }
        if (i >= k - 1)
        {
            if (treap.size > 0)
            {
                writeln(treap.getMaximal());
            }
            else
            {
                writeln("Nothing");
            }
        }
    }
}

int main(string[] args)
{
    int n, k;
    while (readf("%d %d\n", &n, &k) == 2)
    {
        auto a = new int[n];
        foreach (i; 0 .. n)
        {
            readf("%d\n", &a[i]);
        }
        solve(a, k);
    }
    return 0;
}

import std.stdio, std.string;
import std.random;

class Treap(T)
{
    class Node
    {
        Node left;
        Node right;
        T val;
        int priority;

        this()
        {
            left = right = null;
        }

        //int opCmp(Node node)
        //{
            //return this.priority - node.priority;
        //}

        int cmpPriority(int priority)
        {
            if (this.priority == priority) return 0;
            return this.priority < priority ? -1 : 1;
        }

        int cmpVal(T val)
        {
            if (this.val == val) return 0;
            return this.val < val ? -1 : 1;
        }
    }

    protected Node root;
    protected Xorshift rnd;
    protected int size;
    protected T minimal;
    protected T maximal;

    this()
    {
        root = null;
        rnd = Xorshift(1234567891);
        size = 0;
        minimal = T.max;
        maximal = T.min;
    }

    protected void leftRotate(ref Node node)
    {
        if (!node.right) return;
        auto rightNode = node.right;
        if (rightNode)
        {
            node.right = rightNode.left;
            rightNode.left = node;
            node = rightNode;
        }
    }

    protected void rightRotate(ref Node node)
    {
        if (!node.left) return;
        auto leftNode = node.left;
        if (leftNode)
        {
            node.left = leftNode.right;
            leftNode.right = node;
            node = leftNode;
        }
    }

    protected Node find(T val)
    {
        return _find(root, val);
    }

    protected Node _find(Node node, T val)
    {
        if (!node) return null;
        auto ret = node.cmpVal(val);
        if (ret == 0) return node;
        if (ret == -1) return _find(node.right, val);
        return _find(node.left, val);
    }

    public void insert(T val)
    {
        _insert(root, val);
    }

    protected void _insert(ref Node node, T val)
    {
        if (!node)
        {
            node = new Node();
            node.val = val;
            node.priority = this.rnd.front;
            this.rnd.seed(unpredictableSeed);
            ++ size;
            return;
        }
        auto ret = node.cmpVal(val);
        if (ret == 0) return;
        ++ size;
        if (ret == 1)
        {
            _insert(node.left, val);
            if (node.left.priority > node.priority)
            {
                rightRotate(node);
            }
        }
        else if (ret == -1)
        {
            _insert(node.right, val);
            if (node.right.priority > node.priority)
            {
                leftRotate(node);
            }
        }
    }

    public void remove(T val)
    {
        _remove(root, val);
    }

    protected void _remove(ref Node node, T val)
    {
        if (!node) return;
        auto ret = node.cmpVal(val);
        if (ret == 0)
        {
            -- size;
            if (!node.left && !node.right)
            {
                node = null;
                return;
            }
            if (!node.left)
            {
                node = node.right;
                return;
            }
            if (!node.right)
            {
                node = node.left;
                return;
            }
            if (node.left.cmpPriority(node.right.priority) == 1)
            {
                rightRotate(node);
                _remove(node.right, val);
            }
            else
            {
                leftRotate(node);
                _remove(node.left, val);
            }
            return;
        }
        if (ret == -1)
        {
            _remove(node.right, val);
        }
        else
        {
            _remove(node.left, val);
        }
    }

    protected T _getMinimal(Node node)
    {
        if (!node) return minimal;
        if (!node.left) return node.val;
        return _getMinimal(node.left);
    }

    public T getMinimal()
    {
        return _getMinimal(root);
    }

    protected T _getMaximal(Node node)
    {
        if (!node) return maximal;
        if (!node.right) return node.val;
        return _getMaximal(node.right);
    }

    public T getMaximal()
    {
        return _getMaximal(root);
    }

    public void travel()
    {
        _travel(root);
    }

    protected void _travel(Node node)
    {
        if (!node) return;
        _travel(node.left);
        writeln(node.val);
        writeln(node.priority);
        _travel(node.right);
    }

    public void clear()
    {
        while (root)
        {
            remove(root.val);
        }
    }
}

void solve(int[] a, int k)
{
    auto n = cast(int)a.length;
    auto treap = new Treap!int();
    int[int] cnt;
    foreach (i; 0 .. n)
    {
        if (i >= k && a[i - k] != a[i])
        {
            -- cnt[a[i - k]];
            if (cnt[a[i - k]] == 1)
            {
                treap.insert(a[i - k]);
            }
            else
            {
                treap.remove(a[i - k]);
            }
        }
        if (i < k || a[i - k] != a[i])
        {
            if (!(a[i] in cnt))
            {
                cnt[a[i]] = 0;
            }
            ++ cnt[a[i]];
            if (cnt[a[i]] == 1)
            {
                treap.insert(a[i]);
            }
            else
            {
                treap.remove(a[i]);
            }
        }
        if (i >= k - 1)
        {
            if (treap.size > 0)
            {
                writeln(treap.getMaximal());
            }
            else
            {
                writeln("Nothing");
            }
        }
    }
}

int main(string[] args)
{
    int n, k;
    while (readf("%d %d\n", &n, &k) == 2)
    {
        auto a = new int[n];
        foreach (i; 0 .. n)
        {
            readf("%d\n", &a[i]);
        }
        solve(a, k);
    }
    return 0;
}

import std.stdio, std.string;
import std.random;

class Treap(T)
{
    class Node
    {
        Node left;
        Node right;
        T val;
        int priority;

        this()
        {
            left = right = null;
        }

        //int opCmp(Node node)
        //{
            //return this.priority - node.priority;
        //}

        int cmpPriority(int priority)
        {
            if (this.priority == priority) return 0;
            return this.priority < priority ? -1 : 1;
        }

        int cmpVal(T val)
        {
            if (this.val == val) return 0;
            return this.val < val ? -1 : 1;
        }
    }

    protected Node root;
    protected Xorshift rnd;
    protected int size;
    protected T minimal;
    protected T maximal;

    this()
    {
        root = null;
        rnd = Xorshift(1234567891);
        size = 0;
        minimal = T.max;
        maximal = T.min;
    }

    protected void leftRotate(ref Node node)
    {
        if (!node.right) return;
        auto rightNode = node.right;
        if (rightNode)
        {
            node.right = rightNode.left;
            rightNode.left = node;
            node = rightNode;
        }
    }

    protected void rightRotate(ref Node node)
    {
        if (!node.left) return;
        auto leftNode = node.left;
        if (leftNode)
        {
            node.left = leftNode.right;
            leftNode.right = node;
            node = leftNode;
        }
    }

    protected Node find(T val)
    {
        return _find(root, val);
    }

    protected Node _find(Node node, T val)
    {
        if (!node) return null;
        auto ret = node.cmpVal(val);
        if (ret == 0) return node;
        if (ret == -1) return _find(node.right, val);
        return _find(node.left, val);
    }

    public void insert(T val)
    {
        _insert(root, val);
    }

    protected void _insert(ref Node node, T val)
    {
        if (!node)
        {
            node = new Node();
            node.val = val;
            node.priority = this.rnd.front;
            this.rnd.seed(unpredictableSeed);
            ++ size;
            return;
        }
        auto ret = node.cmpVal(val);
        if (ret == 0) return;
        if (ret == 1)
        {
            _insert(node.left, val);
            if (node.left.priority > node.priority)
            {
                rightRotate(node);
            }
        }
        else if (ret == -1)
        {
            _insert(node.right, val);
            if (node.right.priority > node.priority)
            {
                leftRotate(node);
            }
        }
    }

    public void remove(T val)
    {
        _remove(root, val);
    }

    protected void _remove(ref Node node, T val)
    {
        if (!node) return;
        auto ret = node.cmpVal(val);
        if (ret == 0)
        {
            -- size;
            if (!node.left && !node.right)
            {
                node = null;
                return;
            }
            if (!node.left)
            {
                node = node.right;
                return;
            }
            if (!node.right)
            {
                node = node.left;
                return;
            }
            if (node.left.cmpPriority(node.right.priority) == 1)
            {
                rightRotate(node);
                _remove(node.right, val);
            }
            else
            {
                leftRotate(node);
                _remove(node.left, val);
            }
            return;
        }
        if (ret == -1)
        {
            _remove(node.right, val);
        }
        else
        {
            _remove(node.left, val);
        }
    }

    protected T _getMinimal(Node node)
    {
        if (!node) return minimal;
        if (!node.left) return node.val;
        return _getMinimal(node.left);
    }

    public T getMinimal()
    {
        return _getMinimal(root);
    }

    protected T _getMaximal(Node node)
    {
        if (!node) return maximal;
        if (!node.right) return node.val;
        return _getMaximal(node.right);
    }

    public T getMaximal()
    {
        return _getMaximal(root);
    }

    public void travel()
    {
        _travel(root);
    }

    protected void _travel(Node node)
    {
        if (!node) return;
        _travel(node.left);
        writeln(node.val);
        writeln(node.priority);
        _travel(node.right);
    }

    public void clear()
    {
        while (root)
        {
            remove(root.val);
        }
    }
}

void solve(int[] a, int k)
{
    auto n = cast(int)a.length;
    auto treap = new Treap!int();
    int[int] cnt;
    foreach (i; 0 .. n)
    {
        if (i >= k && a[i - k] != a[i])
        {
            -- cnt[a[i - k]];
            if (cnt[a[i - k]] == 1)
            {
                treap.insert(a[i - k]);
            }
            else
            {
                treap.remove(a[i - k]);
            }
        }
        if (i < k || a[i - k] != a[i])
        {
            if (!(a[i] in cnt))
            {
                cnt[a[i]] = 0;
            }
            ++ cnt[a[i]];
            if (cnt[a[i]] == 1)
            {
                treap.insert(a[i]);
            }
            else
            {
                treap.remove(a[i]);
            }
        }
        if (i >= k - 1)
        {
            if (treap.size > 0)
            {
                writeln(treap.getMaximal());
            }
            else
            {
                writeln("Nothing");
            }
        }
    }
}

int main(string[] args)
{
    int n, k;
    while (readf("%d %d\n", &n, &k) == 2)
    {
        auto a = new int[n];
        foreach (i; 0 .. n)
        {
            readf("%d\n", &a[i]);
        }
        solve(a, k);
    }
    return 0;
}

import std.stdio, std.string;
import std.container.rbtree;

void solve(int[] a, int k)
{
    auto n = cast(int)a.length;
    auto rbt = redBlackTree!int();
    int[int] cnt;
    foreach (i; 0 .. n)
    {
        if (i >= k && a[i - k] != a[i])
        {
            -- cnt[a[i - k]];
            if (cnt[a[i - k]] == 1)
            {
                rbt.insert(a[i - k]);
            }
        }
        if (i < k || a[i - k] != a[i])
        {
            if (!(a[i] in cnt))
            {
                cnt[a[i]] = 0;
            }
            ++ cnt[a[i]];
            if (cnt[a[i]] == 1)
            {
                rbt.insert(a[i]);
            }
            else
            {
                rbt.removeKey(a[i]);
            }
        }
        if (i >= k - 1)
        {
            if (rbt.length > 0)
            {
                writeln(rbt.back());
            }
            else
            {
                writeln("Nothing");
            }
        }
    }
}

int main(string[] args)
{
    int n, k;
    while (readf("%d %d\n", &n, &k) == 2)
    {
        auto a = new int[n];
        foreach (i; 0 .. n)
        {
            readf("%d\n", &a[i]);
        }
        solve(a, k);
    }
    return 0;
}


import std.stdio;
import std.string;

private int n;

private int good(string s)
{
    int[26] x;
    int i;
    for (i = 0; i < 26; i++)
        x[i] = 0;
    foreach (c; s)
        x[c - 'a']++;
    for (i = 0; i < 26 && !x[i]; i++) {}
    for (; i < 26 && x[i] == 1; i++) {}
    for (; i < 26 && !x[i]; i++) {}
    return i == 26;
}

void main()
{
    scanf("%d\n", &n);
    for (auto i = 0; i < n; i++)
        writeln(good(readln().strip()) ? "Yes" : "No");
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    while (N--) solve;
}

void solve() {
    auto S = readln.chomp.map!(a => (a - 'a').to!int).array;
    S.sort();
    bool ok = true;
    foreach (i; 0..S.length.to!int-1) {
        if (S[i] + 1 != S[i+1]) {
            ok = false;
        }
    }
    writeln(ok ? "Yes" : "No");
}


import std.stdio;
import std.ascii;
import core.stdc.stdio;
import std.algorithm;
import std.array;
import std.range;

void main()
{
	int t = readInt!int;
	while (t--)
	{
		solve();
	}
}
void solve()
{
	int n = readInt!int;
	int m = readInt!int;
	auto p = new int[](n);
	foreach(ref pi; p) pi = readInt!int - 1;
	int[] kcnt = new int[](n);
	foreach(i, ref pi; p)
	{
		kcnt[((pi-cast(int)i)%n+n)%n]++;
	}
	int[] ks;
	foreach(k; 0 .. n)
	{
		if (kcnt[k] >= n/3)
		{
			debug writeln("trying k = ", k);
			int[] cycledP = new int[](n);
			foreach(i, ref ci; cycledP)
			{
				ci = p[((cast(int)i-k)%n+n)%n];
			}
			debug writeln("cycled is ", cycledP);
			int requiredSwaps = noSwaps(cycledP);
			debug writeln("requires ", requiredSwaps, " swaps");
			if (requiredSwaps <= m)
			{
				ks ~= k;
			}
		}
	}
	auto rks = new int[](ks.length);
	foreach(i, ref rksi; rks)
	{
		rksi = (n-ks[i])%n;
	}
	sort(rks);
	write(ks.length, " ");
	foreach(k; rks) write(k, " ");
	writeln;
}

int noSwaps(int[] p)
{
	bool[] visited = new bool[](p.length);
	void visit(int n)
	{
		assert(!visited[n]);
		visited[n] = true;
		if (!visited[p[n]]) visit(p[n]);
	}
	int g = 0;
	foreach(i; 0 .. cast(int)p.length)
	{
		if (!visited[i])
		{
			visit(i);
			g++;
		}
	}
	return cast(int)p.length - g;
}

/* INPUT ROUTINES */
int currChar;
static this()
{
	currChar = getchar();
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
/**MODULAR SYSTEM*/
struct Z(immutable long m)
{
	long rep;
	this(long num)
	{
		rep = num;
	}

	Z!m opBinary(string operator)(Z!m rhs)
	{
		static if (operator == "+")
		{
			long result = rhs.rep + this.rep;
			if (result >= m)
				result -= m;
			return Z!m(result);
		}
		else static if (operator == "-")
		{
			long result = this.rep - rhs.rep;
			if (result < 0)
				result += m;
			return Z!m(result);
		}
		else static if (operator == "*")
		{
			long result = this.rep * rhs.rep;
			if (result >= m)
				result %= m;
			return Z!m(result);
		}
		else
			static assert(text("Operator ", operator, " not supported"));
	}

	Z!m opBinary(string operator)(long exponent) if (operator == "^^")
	{
		assert(exponent >= 0);
		Z!m base = this;
		Z!m result = 1;
		while (exponent)
		{
			if (exponent & 1)
				result = result * base;
			base = base * base;
			exponent >>= 1;
		}
		return result;
	}

	invariant
	{
		assert(rep >= 0 && rep < m);
	}
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

bool canShift (int n, int m, int [] p, int shift)
{
        auto q = new int [n];
        foreach (i; 0..n)
        {
        	q[i] = (p[i] + n - shift) % n;
        }

	auto used = new bool [n];
	int ops = 0;
	foreach (i; 0..n)
	{
		if (!used[i] && q[i] != i)
		{
			used[i] = true;
			for (int j = q[i]; j != i; j = q[j])
			{
				used[j] = true;
				ops += 1;
			}
		}
	}

	return ops <= m;
}

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		int n, m;
		readf !(" %s %s") (n, m);
		readln;
		auto p = readln.splitter.map !(to !(int)).array;
		p[] -= 1;

		auto d = new int [n];
		foreach (i; 0..n)
		{
			d[(p[i] + n - i) % n] += 1;
		}

		int [] answer;
		foreach (shift; 0..n)
		{
			if (d[shift] + 2 * m >= n)
			{
				if (canShift (n, m, p, shift))
				{
					answer ~= (n - shift) % n;
				}
			}
		}
		sort (answer);

		writefln !("%s%( %s%)") (answer.length, answer);
	}
}


import std.container;
import std.algorithm;
import std.range;
import std.array;
import std.stdio;
import std.utf;
import std.math;
import std.typecons;

alias type = multi;
struct TestCase
{
  mixin prettyPrinting;

  long n;
  @("n") long[] a;

  void solve(long tc = -1)
  {
    auto adjacent = redBlackTree!long();
    foreach(i; 0 .. n)
      {
        if (a.at(i) == -1)
          {
            if (i - 1 >= 0 && a.at(i - 1) != -1)
              adjacent.insert(a.at(i - 1));
            if (i + 1 < n && a.at(i + 1) != -1)
              adjacent.insert(a.at(i + 1));
          }
      }
    if (adjacent.empty)
      {
        writeln(0, " ", 0);
      }
    else
      {
        auto k = (adjacent.front + adjacent.back) / 2;
        foreach(i; 0 .. n)
          if (a.at(i) == -1)
            a.at(i) = k;
        auto m = iota(0, n - 1).fold!((res, i) => max(res, abs(a.at(i) - a.at(i + 1))))(long.min);
        writeln(m, " ", k);
      }
  }
}

mixin template prettyPrinting()
{
  string toString()
  {
    alias structType = typeof(this);
    auto res = appender!(string)();
    res.put(structType.stringof);
    res.put("(");
    static foreach(fieldName; FieldNameTuple!structType)
      {
        res.put(text(" ", fieldName, ": ", mixin(fieldName)));
      }
    res.put(" )");
    res.put("\n");
    return res[];
  }
}

struct Graph(N)
{
  size_t size;
  this(S)(S size)
  {
    adjacencyList.length = cast(size_t) size;
    this.size = cast(size_t) size;
    this.visited = makeSlice!bool(size);
  }
  N[][] adjacencyList;
  alias ne = neighbours;
  N[] neighbours(N n)
  {
    return adjacencyList.at(n);
  }
  alias bcon = biconnect;
  void biconnect(N a, N b)
  {
    adjacencyList.at(a) ~= b;
    adjacencyList.at(b) ~= a;
  }
  alias con = connect;
  void connect(N a, N b)
  {
    adjacencyList.at(a) ~= b;
  }
  void connect(R)(R edges)
  {
    foreach(ref edge; edges)
      {
        connect(edge[0], edge[1]);
      }
  }
  void biconnect(R)(R edges)
  {
    foreach(ref edge; edges)
      {
        biconnect(edge[0], edge[1]);
      }
  }
  alias deg = degree!long;
  auto degree(T)(N a)
  {
    return cast(T) adjacencyList.at(a).length;
  }

  auto visited = new bool[0];
  void dfs(Visitor)(long startNode)
  {
    auto visitor = Visitor.init;
    void internalDfs(long node)
    {
      visited.set(node, true);
      static if (is(typeof({visitor.n = node;})))
        visitor.n = node;
      static if (is(typeof({visitor.pre;})))
        visitor.pre;
      foreach(w; ne(node))
        if (!visited.at(w))
          {
            static if (is(typeof({visitor.w = w;})))
              visitor.w = w;
            static if (is(typeof(visitor.pren)))
              visitor.pren;
            internalDfs(w);
            static if (is(typeof(visitor.postn)))
              visitor.postn;
          }
      static if (is(typeof(visitor.post)))
        visitor.post;
    }
    internalDfs(startNode);
  }
  void dfs(long startNode)
  {
    struct DefVisitor {}
    dfs!DefVisitor(startNode);
  }
}

DList!string _words;

template baseType(W)
{
  static if (isDynamicArray!W)
    alias baseType = baseType!(typeof((delegate() {W w; return w[0];})()));
  else
    alias baseType = W;
}

auto makeSlice(E, W, T...)(W size, T otherSizes)
{
  static if (T.length == 0)
    {
      E[] res;
      res.length = cast(size_t) size;
      return res;
    }
  else
    {
      typeof(makeSlice!E(otherSizes))[] res;
      res.length = cast(size_t) size;
      foreach(ref row; res)
        row = makeSlice!E(otherSizes);
      return res;
    }
}

void read(T...)(ref T t)
{
  void basicTypeRead(W)(ref W w)
  {
    import std.stdio: readln;
    while(_words.empty)
      {
        import std.array: split;
        foreach(word; readln.split)
          {
            _words.insertBack(word);
          }
      }
    import std.conv: to;
    string word = _words.front;
    _words.removeFront;
    w = to!W(word);
  }
  void iterableRead(W)(ref W w)
  {
    foreach(ref element; w)
      read(element);
  }
  void tupleRead(W)(ref W w)
  {
    static foreach(j; 0 .. W.length)
      read(w[j]);
  }
  void structRead(W)(ref W readStruct)
  {
    static foreach(fieldName; FieldNameTuple!W)
      {
        with(readStruct)
          {
            alias fieldSymbol = mixin(W.stringof, ".", fieldName);
            alias typeOfField = typeof(mixin(fieldName));
            static if (hasUDA!(fieldSymbol, string))
              {
                static assert(isDynamicArray!(typeOfField)
                              , " A field with dimension initialization UDA must be a dynamic array.");
                enum uda = getUDAs!(fieldSymbol, string)[0];
                mixin(fieldName) = mixin(q{makeSlice!(baseType!typeOfField)(}, uda, q{)});
              }
            else static if (isDynamicArray!typeOfField && !is(typeOfField == string))
              {
                pragma(msg, "Warning: You probably want to add dimension to input ", fieldName);
              }
            read(mixin(fieldName));
          }
      }
  }
  static foreach(i; 0 .. T.length)
    {
      static if (isBasicType!(T[i]) || is(T[i] == string))
        basicTypeRead(t[i]);
      else static if (is(typeof({foreach(ref e; t[i]){}})))
        iterableRead(t[i]);
      else static if (isTuple!(T[i]))
        tupleRead(t[i]);
      else static if (isAggregateType!(T[i]))
        structRead(t[i]);
    }
}

auto next(T)()
{
  T t;
  read(t);
  return t;
}

size_t ind(T)(T t)
{
  return cast(size_t)t;
}

ref auto at(R, I)(ref R r, I i)
{
  return r[cast(size_t)i];
}

void set(R, I, V)(ref R r, I i, V v)
{
  r[cast(size_t)i] = v;
}

import std.conv;
import std.traits;
import std.meta;
int _loglevel = -1;
void _log(string functionName, argSeq...)()
{
  foreach(i; 0 .. _loglevel * 4)
    write(' ');
  write(functionName);
  static foreach(arg; argSeq)
    {
      write(" ", arg.stringof, " = ", arg);
    }
  writeln;
}
enum logCall =
  q{
    debug
    {
     {
     _loglevel++;
     alias _parameterTuple = ParameterIdentifierTuple!(mixin(split(__FUNCTION__, ".").back));
     static if (_parameterTuple.length > 0)
       mixin(`_log!(__FUNCTION__, `, [_parameterTuple].joiner(", ").array, `);`);
     else
       _log!(__FUNCTION__);
      }
     foreach(i; 0 .. _loglevel * 4) write(' ');
     writeln('{');
     scope(exit)
       {
         foreach(i; 0 .. _loglevel * 4) write(' ');
         writeln('}');
         _loglevel--;
       }
    }
};

void logSym(S...)(int line = __LINE__, string file = __FUNCTION__)
{
  debug
    {
      foreach(i; 0 .. _loglevel * 4) write(' ');
      write(file, "(", line, "):");
      static foreach(s; S)
        write(" ", s.stringof, " = ", s);
      writeln;

    }
}

Array!E makeArray(E, S)(S size, lazy E value)
{
  auto a = Array!E();
  a.length = cast(size_t) size;
  foreach(ref ai; a)
    ai = value();
  return a;
}
Array!E makeArray(E, S)(S size)
{
  auto a = Array!E();
  a.length = cast(size_t) size;
  return a;
}

template mem(alias F)
{
  ReturnType!F[Tuple!(Parameters!F)] table;
  ReturnType!F mem(Parameters!F args)
  {
    return table.require(tuple(args), F(args));
  }
}

string input(string names, string type = "long")
{
  return text(type, " ", names, "; read(", names, ");");
}

auto pmod(T, W)(T t, W w)
{
  return (t%w + w) % w;
}

void rep(S, F)(F f, S times)
{
  static if (is(typeof(f(i))))
    foreach(i; 0 .. times)
      f(i);
  else
    foreach(i; 0 .. times)
      f();
}

void multi()
{
  foreach(tc; 0 .. next!long)
    next!TestCase.solve(tc);
}

void single()
{
  auto tc = next!TestCase;
  tc.solve;
}

void main()
{
  type;
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto t = RD!int;
	auto ans = new long[][](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto a = RDA;
		long b = long.max, c = long.min;
		foreach (i; 0..n)
		{
			if (a[i] != -1) continue;
			if (i != 0)
			{
				if (a[i-1] != -1)
				{
					b.chmin(a[i-1]);
					c.chmax(a[i-1]);
				}
			}
			if (i != n-1)
			{
				if (a[i+1] != -1)
				{
					b.chmin(a[i+1]);
					c.chmax(a[i+1]);
				}
			}
		}
		auto x = (b+c) / 2;
		auto y = max(0, x-b, c-x);
		foreach (i; 1..n)
		{
			if (a[i] != -1 && a[i-1] != -1)
			{
				y.chmax(abs(a[i] - a[i-1]));
			}
		}
		ans[ti] = [y, x];
	}

	foreach (e; ans)
	{
		writeln(e[0], " ", e[1]);
	}
	stdout.flush;
	debug readln;
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	foreach(_; 0 .. rint){
		int n = rint;
		long[] as = rlong(n);
		long l = 1_000_000_000, r = 0;
		foreach(i; 0 .. n){
			if(as[i] >= 0) continue;
			else{
				if(i > 0 && as[i - 1] >= 0) l.chmin(as[i - 1]), r.chmax(as[i - 1]);
				if(i < n - 1 && as[i + 1] >= 0) l.chmin(as[i + 1]), r.chmax(as[i + 1]);
			}
		}
		log("n:", n, "as:", as, "l:", l, "r:", r);
		long ans = 0;
		foreach(i; 0 .. n - 1){
			if(as[i] >= 0 && as[i + 1] >= 0) ans.chmax(abs(as[i + 1] - as[i]));
		}
		ans.chmax((r - l + 1) / 2);

		writeln(ans, " ", (l + r) / 2);
	}
}


import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    auto n = readln.chomp.to!int;

    Tuple!(int, int)[][int][int] mp;
    foreach (int i; 1 .. n+1) {
        auto v = readln.chomp.split.map!(to!int);
        auto x = v[0], y = v[1], z = v[2];

        mp[x][y] ~= tuple(z, i);
    }

    debug { mp.writeln; }

    Tuple!(int, int)[] ans;

    void takePairs(ref int[] arr, ref int[] leftOvers) {
        while (arr.length > 1) {
            auto idx1 = arr.back;
            arr.popBack();
            auto idx2 = arr.back;
            arr.popBack();
            ans ~= tuple(idx1, idx2);
        }

        if (arr.length == 1) {
            leftOvers ~= arr.back;
            arr.popBack();
        }
    }

    int[] lftx;
    foreach (xx; mp.keys.sort()) {
        int[] lfty;
        foreach (yy; mp[xx].keys.sort()) {
            auto values = mp[xx][yy].sort().map!(t => t[1]).array;
            takePairs(values, lfty);
        }

        takePairs(lfty, lftx);
    }

    int[] dummy;
    takePairs(lftx, dummy);

    ans.each!(t => writeln(t[0], ' ', t[1]));
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

immutable int NA = -1;

alias Point = Tuple !(int, q{x}, int, q{y}, int, q{z}, int, q{num});

Point [] p;
bool [] vis;
int [] [] res;
int n;

void loop (alias pred) ()
{
	int i = NA;
	int j = NA;
	foreach (k; 0..n)
	{
		if (!vis[k])
		{
			if (i == NA)
			{
				i = k;
			}
			else
			{
				j = k;
				if (pred (i, j))
				{
					res ~= [p[i].num,
					    p[j].num];
					vis[i] = true;
					vis[j] = true;
					i = NA;
					j = NA;
				}
				else
				{
					i = j;
					j = NA;
				}
			}
		}
	}
}

void main ()
{
	while (readf (" %s", &n) > 0)
	{
		p = new Point [n];
		foreach (i, ref q; p)
		{
			readf (" %s %s %s", &q.x, &q.y, &q.z);
			q.num = i + 1;
		}

		sort (p);
		vis = new bool [n];
		res = null;

		loop !((i, j) => p[i].x == p[j].x && p[i].y == p[j].y);
		loop !((i, j) => p[i].x == p[j].x);
		loop !((i, j) => true);
		writefln ("%(%(%s %)\n%)", res);
	}
}

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0;
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	P[] ps;
	foreach(i; 0 .. n){
		ps ~= P(i, i + 1, rlong, rlong, rlong);
	}

	P[][long][long] pm;
	foreach(p; ps){
		if(p.x !in pm){
			P[][long] tmp;
			pm[p.x] = tmp;
		}
		if(p.y !in pm[p.x]) pm[p.x][p.y] = [];
		pm[p.x][p.y] ~= p;
	}

	int[][] ans;

	long[] xs = pm.keys;
	xs.sort();
	P superleft;
	bool hasSuperleft;
	foreach(x; xs){
		long[] ys = pm[x].keys;
		ys.sort();
		P left;
		bool hasLeft;
		foreach(y; ys){
			P[] pq = pm[x][y];
			pq.sort!isLess();
			foreach(i; 0 .. pq.length / 2){
				ans ~= [pq[i * 2].name, pq[i * 2 + 1].name];
			}
			if(pq.length % 2){
				if(hasLeft){
					ans ~= [pq[$ - 1].name, left.name];
					hasLeft = 0;
				}
				else{
					left = pq[$ - 1];
					hasLeft = 1;
				}
			}
		}
		if(hasLeft){
			if(hasSuperleft){
				ans ~= [left.name, superleft.name];
				hasLeft = 0, hasSuperleft = 0;
			}
			else{
				superleft = left;
				hasLeft = 0, hasSuperleft = 1;
			}
		}
	}

	foreach(an; ans) writeln(an[0], " ", an[1]);
}

struct P{
	int id, name;
	long x, y, z;
}
bool isLess(P a, P b){
	if(a.x != b.x) return a.x < b.x;
	if(a.y != b.y) return a.y < b.y;
	return a.z < b.z;
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

alias Pt = Tuple!(int, "x", int, "y", int, "z", int, "id");

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto P = new Pt[N];
      foreach (i; 0 .. N) {
        P[i].x = readInt();
        P[i].y = readInt();
        P[i].z = readInt();
        P[i].id = i;
      }

      sort(P);

      int[] ans;

      int[] as;
      for (int i = 0, j; i < N; i = j) {
        for (j = i; j < N && P[i].x == P[j].x; ++j) {}
        int[] bs;
        for (int k = i, l; k < j; k = l) {
          for (l = k; l < j && P[k].y == P[l].y; ++l) {}
          foreach (m; k .. k + (l - k) / 2 * 2) {
            ans ~= P[m].id;
          }
          if ((l - k) % 2 != 0) {
            bs ~= P[l - 1].id;
          }
        }
        const bsLen = cast(int)(bs.length);
        foreach (m; 0 .. bsLen / 2 * 2) {
          ans ~= bs[m];
        }
        if (bsLen % 2 != 0) {
          as ~= bs[$ - 1];
        }
      }
      assert(as.length % 2 == 0);
      ans ~= as;

      for (int i = 0; i < N; i += 2) {
        writeln(ans[i] + 1, " ", ans[i + 1] + 1);
      }
    }
  } catch (EOFException e) {
  }
}

import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    alias elem = Tuple!(int, int, int, int);
    elem[] arr;

    foreach (i; 1 .. n+1) {
        int x, y, z;
        readf("%s %s %s", &x, &y, &z);
        readln;

        arr ~= tuple(x, y, z, i);
    }

    arr.sort();

    foreach (cur; n.iota.stride(2)) {
        writeln(arr[cur][3], ' ', arr[cur+1][3]);
    }
}


module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	for(int i = 0; i<1; i++)
		scanf("%d", &n);
	if (n%2==1)
	{
	    printf("7");
	    n-=3;
	}
	for (int i=0;i<n/2;i++)
	{
	    printf("1");
	}
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k;
	scanf("%d %d", &n, &k);
	if(n%2==1)
	{
	    n-=3;
	    printf("7");
	}
	while(n>0)
	{
	    printf("1");
	    n-=2;
	}
	printf("\n");
	return 0;
}

module main;
import std.c.stdio;
int main(string[] args){
	int n; scanf("%d", &n);
	if(n % 2){
		printf("7");
		n -= 3;
	}
	for(int i = 0; i < n / 2; i++)
		printf("1");
	return 0;
}

module main;
import std.c.stdio;
int main(string[] argv)
{
	int n;
	scanf("%d",&n);
	int [] arr = new int[10];
	arr[0]=6;
	arr[1]=2;
	arr[2]=5;
	arr[3]=5;
	arr[4]=4;
	arr[5]=5;
	arr[6]=6;
	arr[7]=3;
	arr[8]=7;
	arr[9]=6;

	int len=n/2;
	for(int i=1;i<=len;i++)
	{
		int ok=-1;
		for(int j=9;j>-1;j--)
		{
			int req=n-arr[j];
			if( req>= (len-i)*2  )
			{
				if(ok==-1)ok=j;
			}
		}
		n=n-arr[ok];
		printf("%d",ok);
	}

	return 0;
}

import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main()
{
    auto nums = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6];
    int n;
    scanf("%d", &n);
    int len = n / 2;

    while (len > 0)
    {
        foreach_reverse (i; 0..10)
            if ((len - 1) * 2 <= n - nums[i])
                {
                    write(i);
                    n -= nums[i];
                    break;
                }
        len = len - 1;
    }
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	if(n > 1) {
	if(n % 2 == 0) printf("1");
	else printf("7");
	for(;n>3;n-=2) printf("1");
	} else {
	printf("0");
	}
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	if(n == 2)
	{
	    printf("%d", 1);
	    return 0;
	}
	else if(n == 3)
	{
	    printf("%d", 7);
	    return 0;
	}
	else
	{
	    if(n % 2 == 1)
	    {
	        n = n - 3;
	        printf("%d", 7);
	    }
	    else
	    {
	        n = n - 2;
	        printf("%d", 1);
	    }

	    while (n > 0)
	    {
	        printf("%d", 1);
	        n = n - 2;
	    }
	}
	return 0;
}

import std.c.stdio;

int main()
{
    long n;

    scanf("%d", &n);

    long co = n/2;

    if(n%2 == 1){
        co--;
        printf("%d", 7);
    }
    for(long i=0;i<co;i++)
        printf("%d", 1);

    return 0;
}

module main;

import core.stdc.stdio;

int main(string[] argv) {
	int n = 0;
	scanf("%d", &n);
	if((n & 1) == 1) {
		n -= 3;
		putchar('7');
	}
	for(int i = 0; i < n; i += 2)
		putchar('1');
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{

int n, one, seven, a1, a7;

a1 = 1;
	a7 = 7;

scanf("%d", &n);

if (n % 2 == 1) {seven = 1; one = (n - 3) / 2;}

else {one = n / 2;}

for (int i = 0; i < seven; i++) printf("%d", a7);

for (int i = 0; i < one; i++) printf("%d", a1);

return 0;
}

import std.stdio;

void main()
{
    int n;
    scanf("%d", &n);
    if (n % 2 == 1) { write('7'); n -= 3; }
    for (; n > 0; n -= 2) write('1');
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	if (n%2 == 1)
		printf("%d", 7);
	else
		printf("%d", 1);

	for(int i = 0; i<n/2-1; i++)
		printf("1");

	return 0;
}

import std.bigint,std.container,std.array,std.algorithm,std.conv,
	std.functional,std.math,std.numeric,std.string,std.range,std.complex,
	std.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,
	core.stdc.stdio : freopen;
import core.stdc.stdlib : system;
//import core.stdc.stdio;
alias RedBlackTree Rbt;alias redBlackTree rbt;alias BigInt big;alias pair(X,Y)=Tuple!(X,"fi",Y,"se");
alias pair!(int,int) pii;alias pair!(long,long) pll;alias BoyerMooreFinder strfind;alias long lint;
alias make_pair mp;alias binary_search bins;alias gcd=std.numeric.gcd;immutable int mod=1000000007;
pure nothrow
{
	T lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}
	pair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,"fi",Y,"se")(x_,y_);}
	big gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}
	@property X sqr(X)(in X a_) {return a_*a_;}
	@property X cub(X)(in X a_) {return a_*a_*a_;}
	size_t lowb(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(!(a[m]<g))r=m;
			else l=m;
		}
		return (!(a[l]<g))?l:r;
	}
	size_t upb(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		if(pos==a.length)return pos;
		else return a[pos]==g?pos+1:pos;
	}
	size_t binf(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		return (g==a[pos])?pos:a.length;
	}
	bool binary_search(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		return binf(a,g)!=a.length;
	}
}
void putarr(X)(in X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(in X a,in size_t n=a.length,in size_t m=a.front.length)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
bool getarr(X)(X a,in size_t n)
{bool b=1; foreach(ref i;a[0..n])b=input(&i);return b;}
bool input(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	return s==ptrs.length;
}
bool read(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	readln;
	return s==ptrs.length;
}
void main()
{
    int n;
read(n);
if(((n/2)*2) != n) {
write(7);
n = n - 3;
}
while(n>=2){
write(1);
n = n - 2;
}
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int m = n / 2, k = n % 2;
	if(k == 1){
    printf("7");
    --m;
    }
	while(m--)printf("1");
	return 0;
}

import std.stdio;

void main()
{
    long x, i;
    readf(" %s", &x);
    if (x % 2 == 1)
    {
        write(7);
        x -= 3;
    }
    for (i = 0; i < x; i += 2)
        write(1);
}

module main;

import core.stdc.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
    if(n%2==1){
        printf("7");
    }else{
        printf("1");
    }
	for(int i = 0; i<n/2-1; i++)
		printf("1");
	return 0;
}

module main;
import std.c.stdio;
int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	if(n % 2 == 0)
	{
	   for(int i = 0; i < n / 2; i++)
	        printf("1");
	}
	else
	{
	    printf("7");
	    n -= 3;
	    for(int i = 0; i < n / 2; i++)
	        printf("1");
	}
	return 0;
}

module main;
import std.c.stdio;
int main(string[] argv)
{
    int number;
    scanf("%d",&number);
    if(number%2==0)
    {
        for(int i=1;i<=number/2;++i) printf("1");
    }
    else{
        printf("7");
        for(int i=1;i<=(number-3)/2;++i) printf("1");
    }
    return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	for(;n>3;n-=2) printf("1");
	if(n == 3) printf("7");
	else printf("1");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	int m = n / 3, k = n % 3;
	if(k == 1){
	m--;
	if(m<0)m=0;
	k=2;
	} else
	if(k==2)k = 1;
	while(m--)printf("7");
	while(k--)printf("1");
	return 0;
}

module main;
import std.c.stdio;
int main(string[] args){
	int n; scanf("%d", &n);
	if(n % 2){
		printf("7");
		n -= 3;
	}
	for(int i = 0; i < n / 2; i++)
		printf("2");
	return 0;
}

module main;
import std.c.stdio;
int main(string[] argv)
{
	int n;
	scanf("%d",&n);
	int [] arr = new int[10];
	arr[0]=6;
	arr[1]=2;
	arr[2]=5;
	arr[3]=5;
	arr[4]=4;
	arr[5]=5;
	arr[6]=6;
	arr[7]=3;
	arr[8]=7;
	arr[9]=6;
	int len=n/2;
	for(int i=1;i<=len;i++)
	{
		int ok=-1;
		for(int j=9;j>-1;j--)
		{
			int req=n-arr[j];
			if( req>= (len-i)*2  )
			{
				if(ok==-1)ok=j;
			}
		}
		printf("%d",ok);
	}

	return 0;
}

import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main()
{
    auto nums = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6];
    int n;
    scanf("%d", &n);
    int len = n / 2;

    while (len > 0)
    {
        foreach_reverse (i; 0..10)
            if ((len - 1) * 2 <= n - nums[i])
                {
                    write(i);
                    break;
                }
        len = len - 1;
    }
}

import std.bigint,std.container,std.array,std.algorithm,std.conv,
	std.functional,std.math,std.numeric,std.string,std.range,std.complex,
	std.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,
	core.stdc.stdio : freopen;
import core.stdc.stdlib : system;
//import core.stdc.stdio;
alias RedBlackTree Rbt;alias redBlackTree rbt;alias BigInt big;alias pair(X,Y)=Tuple!(X,"fi",Y,"se");
alias pair!(int,int) pii;alias pair!(long,long) pll;alias BoyerMooreFinder strfind;alias long lint;
alias make_pair mp;alias binary_search bins;alias gcd=std.numeric.gcd;immutable int mod=1000000007;
pure nothrow
{
	T lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}
	pair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,"fi",Y,"se")(x_,y_);}
	big gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}
	@property X sqr(X)(in X a_) {return a_*a_;}
	@property X cub(X)(in X a_) {return a_*a_*a_;}
	size_t lowb(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		size_t l=0,r=a.length;
		while(r-l>1)
		{
			auto m=(l+r)>>1;
			if(!(a[m]<g))r=m;
			else l=m;
		}
		return (!(a[l]<g))?l:r;
	}
	size_t upb(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		if(pos==a.length)return pos;
		else return a[pos]==g?pos+1:pos;
	}
	size_t binf(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		auto pos=lowb(a,g);
		return (g==a[pos])?pos:a.length;
	}
	bool binary_search(T,X)(in T a,auto ref X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g<a[0])==bool))
	{
		return binf(a,g)!=a.length;
	}
}
void putarr(X)(in X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}
void putarr(X)(in X a,in size_t n=a.length,in size_t m=a.front.length)
{
	foreach(i;0..n)
	{
		foreach(j;0..m)write(a[i][j],' ');
		writeln;
	}
}
bool getarr(X)(X a,in size_t n)
{bool b=1; foreach(ref i;a[0..n])b=input(&i);return b;}
bool input(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	return s==ptrs.length;
}
bool read(T...)(auto ref T ptrs) if (ptrs.length > 0)
{
	size_t s=0;
	foreach(ref e;ptrs)
	{
		s+=readf(" %s",&e);
	}
	readln;
	return s==ptrs.length;
}
void main()
{
    int n;
read(n);
if(n%3 != 0) {
write(7);
n = n - 3;
}
while(n>=2){
write(1);
n = n - 2;
}
}


import std.stdio;
import std.algorithm;
import std.range;
import std.string;
import std.array;
import std.conv;
import std.math;

int main(string[] argv)
{
	int n = to!int(readln.split[0] , 10);

	string[] s = new string[n];
	for(int i = 0;i < n;i++){
		s[i] = readln;
	}
	s.sort();
	int[] h = new int[n];
	int[] m = new int[n];
	for(int i = 0;i < n;i++){
	      auto x = s[i].split(':');
	     // writeln(x);
	      h[i] = to!int(x[0],10);
		m[i] = to!int(x[1].split('\n')[0],10);
// 		writeln(h[i] , m[i]);
	}
	int d = 0;
	for(int i = 0;i < n - 1;i++){
	      int x = 60 * (h[i + 1] - h[i]) + m[i + 1] - m[i] - 1;
	     // writeln(x);
	      if(d < x)d = x;
	}
	int x = 60 * (23 - h[n - 1]) + 60 - m[n - 1] + 60 * h[0] + m[0] - 1;
	if(d < x)d = x;
	int a = d % 60;
	d = (d - a)/60;
      if(d < 10){
            if(a < 10)writeln("0" , to!string(d) , ":0" , to!string(a));
            else writeln("0" , to!string(d) , ":" , to!string(a));
      }
	else {
	      if(a < 10)writeln(to!string(d) , ":0" , to!string(a));
	      else writeln(to!string(d) , ":" , to!string(a));
	}
	return 0;
}

import std.stdio;

void main(string[] args) {
   int n;
   int[1440] time;
   scanf("%d", &n);
   for ( int i = 0; i < 1440; i++ ) {
      time[ i ] = 0;
   }
   int h, m;
   for ( int i = 0; i < n; i++ ) {
      scanf("%d:%d", &h, &m);
      time[h*60+m] = 1;
   }
   int mm=0;
   int cur=0;
   int cur1=0;
   int t = 0;
   for ( int i = 0; i < 1440; i++){
      if (time[i] == 0){
        cur = cur + 1;
      }
      else {
        if (t == 0){
            cur1 = cur;
            cur = 0;
            t = 1;
        }
        if (cur > mm){
            mm = cur;
        }
        cur = 0;
      }
   }
   if (cur+cur1 > mm){
        mm = cur+cur1;
    }
   writeln(mm/60/10,mm/60%10,":",mm%60/10,mm%60%10);
}

import std.stdio;

int[8888] cnt;

int main() {
    int n;

    readf("%d\n", &n);

    for (int i = 0; i < n - 1; i++) {
    	int h, m;

    	readf("%d:%d\n", &h, &m);
    	int x = h * 60 + m;
    	cnt[x] = 1;

    	cnt[x + 24 * 60] = 1;
    }

       	int h, m;

    	readf("%d:%d", &h, &m);
    	int x = h * 60 + m;
    	cnt[x] = 1;

    	cnt[x + 24 * 60] = 1;

    int ans = 0, cur = 0;

    for (int i = 0; i < 2 * 24 * 60; i++) {

    	if (cnt[i] == 1) {
    		if (ans < cur) {
    		        ans = cur;
    		    }
    		cur = 0;
    	} else cur++;

    }

    if (ans < cur) {
        ans = cur;
    }

    printf("%02d:%02d", ans/60, ans % 60);

    return 0;
}

module main;

import std.c.stdio;
import std.algorithm;

int main(string[] argv)
{
	int n;
	scanf("%d", &n);
	if (n == 1) {
		printf("23:59");
		return 0;
	}
	int cm = 0;
	int time = 0;
	int[] ms = new int[n];
	for (int i = 0; i < n; ++i) {
		getchar();
		int h = (getchar() - '0') * 10 + getchar() - '0';
		getchar();
		int m = (getchar() - '0') * 10 + getchar() - '0';
		ms[i] = 60 * h + m;
	}
	ms.sort();
	int dif = ms[0] + 24 * 60 - ms[n - 1];
	for (int i = 1; i < n; ++i) {
		if (ms[i] - ms[i - 1] > dif) {
			dif = ms[i] - ms[i - 1];
		}
	}
	--dif;
	int h1 = dif / 60;
	dif = dif - 60 * h1;
	printf("%d%d:%d%d", h1 / 10, h1 % 10, dif / 10, dif % 10);
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;
int main(string[] argv)
{
	int n, h,m,ot, z,a;
	ot = 0;
	scanf("%d", &n);

	int [] t = new int[n];

	for(int i = 0; i<n; i++)
	{
		scanf("%d:%d", &h, &m);
		t[i] = h*60+m;
	}
	t.sort();
	z=t[0]+24*60;
	for(int i = 1; i<n; i++)
	{
	    if (t[i]-t[i-1]-1>ot) ot=t[i]-t[i-1]-1;
	}
	if (z-t[n-1]-1>ot) ot=z-t[n-1]-1;
	a = ot/60;
	if (a<10) printf("0%d:",a);
	else printf("%d:",a);
	a = ot%60;
	if (a<10) printf("0%d",a);
	else printf("%d",a);
	return 0;
}

module main;
import std.c.stdio;

int main(string[] argv)
{
	int [] arr = new int[105];

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int h, m;
		char c;
		scanf("%d%c%d", &h, &c, &m);
		int now = h * 60 + m;
		arr[i] = now;
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = n - 1; j >= i + 1; j--)
		{
			if (arr[j] < arr[j - 1])
			{
				int t = arr[j - 1];
				arr[j - 1] = arr[j];
				arr[j] = t;
			}
		}
	}
	arr[n] = arr[0] + 24 * 60;
	n++;

	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		if (ans < arr[i] - arr[i - 1] - 1)
			ans = arr[i] - arr[i - 1] - 1;
	}

	int h = ans / 60, m = ans % 60;

	if (h < 10)
		printf("0%d", h);
	else
		printf("%d", h);
	printf(":");
	if (m < 10)
		printf("0%d", m);
	else
		printf("%d", m);

	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;

int main (string[] argv)
{
	int n;
	scanf ("%d", &n);
	int [] arr = new int[n + 1];
	for (int i = 0, h, m; i < n; i++) {
		scanf("%d:%d", &h, &m);
		arr[i] = h * 60 + m;
	}
	arr[n] = 1000000000;
	sort (arr);
	arr[n] = arr[0] + 24 * 60;

	int ans = -1;
	for (int i = 1; i <= n; i++) {
		ans = max (ans, arr[i] - arr[i - 1] - 1);
	}
	printf ("%02d:%02d\n", ans / 60, ans % 60);

	return 0;
}

module main;
import std.c.stdio;
import std.algorithm.sorting;

int n;
int[] ar = new int[1111];

void read()
{
    for(int i = 0 ; i < 1111 ; i ++) ar[i] = 2147483647;
	scanf("%d", &n);
	for(int i = 0 ; i < n ; i ++)
	{
	    char c;
		int h, m; scanf("%d%c%d", &h, &c, &m);
		ar[i] = (h * 60) + m;
	}
}

int solve()
{
	int res = 0;

	sort(ar);

	ar[n] = ar[0] + 24 * 60;
	for(int i = 1 ; i <= n ; i ++)
	{
		if(res < ar[i] - ar[i - 1] - 1)
		{
			res = ar[i] - ar[i - 1] - 1;
		}
	}
	return res;
}

void print(int s)
{
	int h = s / 60;
	int m = s % 60;

	if (h < 10)
		printf("0%d", h);
	else
		printf("%d", h);

	printf(":");

	if (m < 10)
		printf("0%d", m);
	else
		printf("%d", m);
}

int main(string[] argv)
{
	read();
	print(solve());
	return 0;
}

import std.stdio, std.array, std.conv, std.algorithm;

void main()
{
    auto max = 0;
    stdin.readln();
    auto arr = stdin
        .byLineCopy
        .array
        .sort!((a, b) => a < b) // descending order
        .map!(l => l.split(":"))
        .map!(l => to!int(l[0]) * 60 + to!int(l[1]));
    for (int i = 0; i < arr.length; i++) {
        if (i < arr.length - 1 && arr[i + 1] - arr[i] > max) max = arr[i + 1] - arr[i];
        if (i == arr.length - 1 && arr[0] + 1440 - arr[i] > max) max = arr[0] + 1440 - arr[i];
    }
    max = max - 1;
    printf("%02d:%02d", max / 60, max % 60);
}

import std.stdio;

int[3500] cnt;

int main() {
    int n;
    readf("%d\n", &n);

    for (int i = 0; i < n; i++) {
    	int h, m;
    	readf("%d:%d\n", &h, &m);
    	int x = h * 60 + m;
    	cnt[x] = 1;
    	cnt[x + 24 * 60] = 1;
    }

    int ans = 0, cur = 0;
    for (int i = 0; i < 2 * 24 * 60; i++) {
    	if (cnt[i] == 1) {
    		if (ans < cur) ans = cur;
    		cur = 0;
    	} else cur++;
    }

    if (ans < cur) ans = cur;
    printf("%02d:%02d", ans/60, ans % 60);

    return 0;
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++){
	    int h,m;
		scanf("%d:%d", &h,&m);
		h*=60;
		arr[i] = h+m;
	}
	arr.sort();
	int mx=0;
	for(int i=0;i<n-1;i++){
		int dif = arr[i+1] - arr[i] - 1;
		if(dif>mx)mx = dif;
	}
	int dif = 1440 - arr[n-1] + arr[0] - 1;
	if(dif>mx)mx=dif;
	if(n==1){
		printf("23:59\n");
	}
	if(n!=1){
	    if(mx/600==0){
	        printf("0");
	    }
		printf("%d:", mx/60);
		if((mx-mx/60*60)/10 == 0){
		    printf("0");
		}
		printf("%d\n",mx-mx/60*60);
	}
	return 0;
}

module main;
import core.stdc.stdio;
import std.algorithm;

int main(string[] argv)
{
    int n, ans = 0;
    scanf("%d", &n);
    int[] t = new int[n];
    for (int i = 0; i < n; ++i) {
        int h, m;
        scanf("%d:%d", &h, &m);
        t[i] = 60*h+m;
    }
    if (n == 1) {
        puts("23:59");
        return 0;
    }
    t.sort();

    for (int i = 1; i < n; ++i) {
        int v = t[i]-t[i-1]-1;
        if (v > ans) ans = v;
    }
    int tmp = 60*24+t[0]-t[n-1]-1;
    if (tmp > ans) ans = tmp;
    printf("%02d:%02d\n", ans/60, ans%60);

    return 0;
}

//Written by libra9z,Use D
module main;
import core.stdc.stdio;
import std.algorithm;
int max(int a,int b)
{
    if(a>b) return a;
	else return b;
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1)
	{
        printf("23:59");
        return 0;
    }
    int [] arr=new int[n];
    for(int i=0;i<n;i++)
	{
        int a,b;
        scanf("%d:%d",&a,&b);
        arr[i]=a*60+b;
    }
    arr.sort();
    int ans=arr[0]+(24*60-arr[n-1]);
    for(int i=0;i<n-1;i++)
	{
        ans=max(ans,arr[i+1]-arr[i]);
    }
    ans--;
    printf("%02d:%02d",ans/60,ans%60);
    return 0;
}

//Written by libra9z,Use D
module main;
import core.stdc.stdio;
int max(int a,int b)
{
    if(a>b) return a;
	else return b;
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1)
	{
        printf("23:59");
        return 0;
    }
    int [] arr=new int[105];
    for(int i=0;i<n;i++)
	{
        int a,b;
        scanf("%d:%d",&a,&b);
        arr[i]=a*60+b;
    }
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<n;j++)
		{
            if(arr[i]<arr[j])
			{
                int t=arr[i];
                arr[i]=arr[j];
                arr[j]=t;
            }
        }
    }
    int ans=arr[0]+(24*60-arr[n-1]);
    for(int i=0;i<n-1;i++)
	{
        ans=max(ans,arr[i+1]-arr[i]);
    }
    ans--;
    printf("%02d:%02d",ans/60,ans%60);
    return 0;
}

//Written by libra9z,Use D
module main;
import core.stdc.stdio;
import std.algorithm;
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1)
	{
        printf("23:59");
        return 0;
    }
    int [] arr=new int[n];
    for(int i=0;i<n;i++)
	{
        int a,b;
        scanf("%d:%d",&a,&b);
        arr[i]=a*60+b;
    }
    arr.sort();
    int ans=arr[0]+(24*60-arr[n-1]);
    for(int i=0;i<n-1;i++)
	{
        ans=max(ans,arr[i+1]-arr[i]);
    }
    ans--;
    printf("%02d:%02d",ans/60,ans%60);
    return 0;
}

module main;

import core.stdc.stdio ;

int main()
{
	int n,l,r,q,k=0,j=0,ans=0,low,mid,i;
	scanf("%d", &q);
	int [] a = new int[1000005];

    for(i=0;i<q;i++)
    {
        scanf("%d:%d",&l,&r);
         k=l*60+r;
        a[k]++;
        a[k+1440]++;
    }
    for(i=0;i<2879;i++){
    if(a[i]==0) j++;
    else {
        if(ans<j) ans=j;
        j=0;
    }
    }
    if(ans<j) ans=j;
    int hh=ans/60;
    int mm=ans%60;
    if(hh<10) printf("0%d:",hh);
    else printf("%d:",hh);

    if(mm<10) printf("0%d",mm);
    else printf("%d",mm);
	return 0;
}

module main;
import core.stdc.stdio;

int max(int a,int b){
    if(a>b) return a; else return b;
}

int main(){
    int n;
    scanf("%d",&n);
    if(n==1){
        printf("23:59");
        return 0;
    }

    int [] arr=new int[105];
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d:%d",&a,&b);
        //printf("%d %d",a,b);

        arr[i]=a*60+b;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(arr[i]<arr[j]){
                int t=arr[i];
                arr[i]=arr[j];
                arr[j]=t;
            }
        }
    }

    // for(int i=0;i<n;i++){
    //     printf("%d ",arr[i]);
    // }

    int ans=arr[0]+(24*60-arr[n-1]);
    for(int i=0;i<n-1;i++){
        ans=max(ans,arr[i+1]-arr[i]);
    }
    ans--;
    printf("%02d:%02d",ans/60,ans%60);
    return 0;
}

module main;

import std.stdio;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] a = new int[1005];
	int [] b = new int[1005];
	int [] c = new int[1005];
	for(int i = 1; i<=n; i++)
		scanf("%d:%d", &a[i],&b[i]);
	for(int i=1;i<=n;i++)
	{

	c[i]=a[i]*60+b[i];//printf("%d ",c[i]);
	}
	for(int i=1;i<=n;i++)
	{
		int minn=100000000,pla=0,j;
		for(j=i;j<=n;j++)
		{
			if(c[j]<minn)
			{
				minn=c[j];
				pla=j;
			}
		}
		//printf("pla:%d",pla);
		int t=c[pla];
		c[pla]=c[i];
		c[i]=t;
	}
	int ans=0;
	for(int i=1;i<n;i++)
	{
	//printf("%d ",c[i]);
	if(c[i+1]-c[i]>ans) ans=c[i+1]-c[i];
	}
	if(n==1)
	{
		printf("23:59");
		return 0;
	}
	else
	{
	if(1440-c[n]+c[1]>ans) ans=1440-c[n]+c[1];
		ans--;
		printf("%02d:%02d",ans/60,ans%60);
	}
	return 0;
}

module main;

import std.c.stdio;

int dig(char c){
    c -= '0';
    return c <= 9 ? c : -1;
}

int main(string[] argv)
{
	char[] arr = new char[15];
    int t = 24 * 60;
    int[] a = new int[t];
    for(int i = 0; i < t; i++) a[i] = 0;
	int n;
	scanf("%d", &n);
	for(int i = 0; i<n; i++){

	    for(int j = 0; j < 15; j++) arr[j] = 0;
	    scanf("%s", &arr[0]);
	    //printf("%c\n", arr[0]);
	    int u = dig(arr[0]), uu = dig(arr[1]), v = dig(arr[3]), vv = dig(arr[4]);
	    //printf("%d\n", 60 * (10 * u + uu) + (10 * v + vv));
	    a[60 * (10 * u + uu) + (10 * v + vv)] = 1;
	}

	int mxmin = 1;
	for(int i = 0; i < t; i++){
	    // start at time i
	    if(a[i] != 1){
	        for(int j = 0; j < t; j++){
	            if(a[(i + j) % t] == 1){
	                if(mxmin < j) mxmin = j;
	                break;
	            }
	        }
	    }
	}

	int hrs = mxmin / 60;
	int mns = mxmin - 60 * hrs;

	if(hrs < 10) printf("%d", 0);
	printf("%d", hrs);

	printf(":");

	if(mns < 10) printf("%d", 0);
	printf("%d\n", mns);

	return 0;
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++){
	    int h,m;
		scanf("%d:%d", &h,&m);
		h*=60;
		arr[i] = h+m;
	}
	arr.sort();
	int mx=0;
	for(int i=0;i<n-1;i++){
		int dif = arr[i+1] - arr[i] - 1;
		if(dif>mx)mx = dif;
	}
	if(n==1){
		printf("23:59\n");
	}
	if(n!=1){
	    if(mx/600==0){
	        printf("0");
	    }
		printf("%d:", mx/60);
		if((mx-mx/60*60)/10 == 0){
		    printf("0");
		}
		printf("%d\n",mx-mx/60*60);
	}
	return 0;
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++){
	    int h,m;
		scanf("%d:%d", &h,&m);
		h*=60;
		arr[i] = h+m;
	}
	arr.sort();
	int mx=0;
	for(int i=0;i<n-1;i++){
		int dif = arr[i+1] - arr[i] - 1;
		if(dif>mx)mx = dif;
	}
	int dif = 1320 - arr[n-1] + arr[0];
	if(dif>mx)mx=dif;
	if(n==1){
		printf("23:59\n");
	}
	if(n!=1){
	    if(mx/600==0){
	        printf("0");
	    }
		printf("%d:", mx/60);
		if((mx-mx/60*60)/10 == 0){
		    printf("0");
		}
		printf("%d\n",mx-mx/60*60);
	}
	return 0;
}

import std.stdio;
import std.uni;
import std.string;
import core.stdc.stdio;
import std.array;
import std.algorithm;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++){
	    int h,m;
		scanf("%d:%d", &h,&m);
		h*=60;
		arr[i] = h+m;
	}
	arr.sort();
	int mx=0;
	for(int i=0;i<n-1;i++){
		int dif = arr[i+1] - arr[i] - 1;
		if(dif>mx)mx = dif;
	}
	int dif = 1440 - arr[n-1] + arr[0];
	if(dif>mx)mx=dif;
	if(n==1){
		printf("23:59\n");
	}
	if(n!=1){
	    if(mx/600==0){
	        printf("0");
	    }
		printf("%d:", mx/60);
		if((mx-mx/60*60)/10 == 0){
		    printf("0");
		}
		printf("%d\n",mx-mx/60*60);
	}
	return 0;
}

import core.bitop;
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.exception;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int main(string[] argv)
{
	int n,k;
	scanf("%d", &n);
	int [] arr = new int[n];
	for(int i = 0; i<n; i++){
	    int h,m;
		scanf("%d:%d", &h,&m);
		h*=60;
		arr[i] = h+m;
	}
	arr.sort();
	int mx=0;
	for(int i=0;i<n-1;i++){
		int dif = arr[i+1] - arr[i] - 1;
		if(dif>mx)mx = dif;
	}
	int dif = arr[n-1] - arr[0] - 1;
	if(dif>mx)mx=dif;
	if(n==1){
		printf("23:59\n");
	}
	if(n!=1){
	    if(mx/600==0){
	        printf("0");
	    }
		printf("%d:", mx/60);
		if((mx-mx/60*60)/10 == 0){
		    printf("0");
		}
		printf("%d\n",mx-mx/60*60);
	}
	return 0;
}

module main;

import core.stdc.stdio ;

int main()
{
	int n,l,r,q,k=0,j=0,ans=0,low,mid,i;
	scanf("%d", &q);
	int [] a = new int[1000005];

    for(i=0;i<q;i++)
    {
        scanf("%d:%intd",&l,&r);
         k=l*60+r;
        a[k]++;
        a[k+1440]++;
    }
    for(i=0;i<2880;i++){
    if(a[i]==0) j++;
    else {
        if(ans<j) ans=j;
        j=0;
    }
    }
    if(ans<j) ans=j;
    int hh=ans/60;
    int mm=ans%60;
    if(hh<10) printf("0%d:",hh);
    else printf("%d:",hh);

    if(mm<10) printf("0%d",mm);
    else printf("%d",mm);
	return 0;
}

module main;

import core.stdc.stdio ;

int main()
{
	int n,l,r,q,k=0,j=0,ans=0,low,mid,i;
	scanf("%d", &q);
	int [] a = new int[1000005];

    for(i=0;i<q;i++)
    {
        scanf("%d:%intd",&l,&r);
         k=l*60+r;
        a[k]++;
        a[k+1440]++;
    }
    for(i=0;i<2880;i++){
    if(a[i]==0) j++;
    else {
        if(ans<j) ans=j;
        j=0;
    }
    }
    if(ans<j) ans=j;
    printf("%d:%d",ans/60,ans%60);
	return 0;
}

module main;
import core.stdc.stdio;

int max(int a,int b){
    if(a>b) return a; else return b;
}

int main(){
    int n;
    scanf("%d",&n);
    if(n==1){
        printf("23:59");
        return 0;
    }

    int [] arr=new int[105];
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d:%d",&a,&b);
        //printf("%d %d",a,b);

        arr[i]=a*60+b;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(arr[i]<arr[j]){
                int t=arr[i];
                arr[i]=arr[j];
                arr[j]=t;
            }
        }
    }

    // for(int i=0;i<n;i++){
    //     printf("%d ",arr[i]);
    // }

    int ans=arr[0]+(24*60-arr[n-1])-1;
    for(int i=0;i<n-1;i++){
        ans=max(ans,arr[i+1]-arr[i]);
    }
    ans--;
    printf("%02d:%02d",ans/60,ans%60);
    return 0;
}

import std.stdio;
import std.algorithm;
import std.range;
import std.string;
import std.array;
import std.conv;
import std.math;

int main(string[] argv)
{
	int n = to!int(readln.split[0] , 10);

	string[] s = new string[n];
	for(int i = 0;i < n;i++){
		s[i] = readln;
	}
	s.sort();
	int[] h = new int[n];
	int[] m = new int[n];
	for(int i = 0;i < n;i++){
	      auto x = s[i].split(':');
	     // writeln(x);
	      h[i] = to!int(x[0],10);
		m[i] = to!int(x[1].split('\n')[0],10);
// 		writeln(h[i] , m[i]);
	}
	int d = 0;
	for(int i = 0;i < n - 1;i++){
	      int x = 60 * (h[i + 1] - h[i]) + m[i + 1] - m[i] - 1;
	     // writeln(x);
	      if(d < x)d = x;
	}
	int x = 60 * (23 - h[n - 1]) + 60 - m[n - 1] + 60 * h[0] + m[0] - 1;
	if(d < x)d = x;
	int a = d % 60;
	d = (d - a)/60;
// 	writeln(d);
// 	writeln(a);
	writeln(to!string(d) , ":" , to!string(a));
	return 0;
}

import std.stdio;
import std.algorithm;
import std.range;
import std.string;
import std.array;
import std.conv;
import std.math;

int main(string[] argv)
{
	int n = to!int(readln.split[0] , 10);

	string[] s = new string[n];
	for(int i = 0;i < n;i++){
		s[i] = readln;
	}
	s.sort();
	int[] h = new int[n];
	int[] m = new int[n];
	for(int i = 0;i < n;i++){
	      auto x = s[i].split(':');
	     // writeln(x);
	      h[i] = to!int(x[0],10);
		m[i] = to!int(x[1].split('\n')[0],10);
// 		writeln(h[i] , m[i]);
	}
	int d = 0;
	for(int i = 0;i < n - 1;i++){
	      int x = 60 * (h[i + 1] - h[i]) + m[i + 1] - m[i] - 1;
	     // writeln(x);
	      if(d < x)d = x;
	}
	int x = 60 * (23 - h[n - 1]) + 60 - m[n - 1] + 60 * h[0] + m[0] - 1;
	if(d < x)d = x;
	int a = d % 60;
	d = (d - a)/60;
// 	writeln(d);
// 	writeln(a);
      if(d < 10)writeln("0" , to!string(d) , ":" , to!string(a));
	else writeln(to!string(d) , ":" , to!string(a));
	return 0;
}

module main;
import std.c.stdio;
import std.algorithm.sorting;

int n;
int[] ar = new int[1111];

void read()
{
	scanf("%d", &n);
	for(int i = 0 ; i < n ; i ++)
	{
		int h, m; scanf("%d %d", &h, &m);
		ar[i] = (h * 60) + m;
	}
}

int solve()
{
	int res = 0;
	ar.sort();
	ar[n] = ar[0] + 24 * 60;
	for(int i = 1 ; i <= n ; i ++)
		if(res < ar[i] - ar[i - 1] - 1)
			res = ar[i] - ar[i - 1] - 1;
	return res;
}

void print(int s)
{
	int h = s / 60;
	int m = s % 60;

	if (h < 10)
		printf("0%d", h);
	else
		printf("%d", h);

	printf(":");

	if (m < 10)
		printf("0%d", m);
	else
		printf("%d", m);
}

int main(string[] argv)
{
	read();
	print(solve());
	return 0;
}

module main;
import std.c.stdio;

int main(string[] argv)
{
	int [] arr = new int[105];

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int h, m;
		char c;
		scanf("%d%c%d", &h, &c, &m);
		int now = h * 60 + m;
		arr[i] = now;
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = n - 1; j >= i + 1; j--)
		{
			if (arr[j] < arr[j - 1])
			{
				int t = arr[j - 1];
				arr[j - 1] = arr[j];
				arr[j] = t;
			}
		}
	}
	arr[n] = arr[0] + 24 * 60;
	n++;

	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		if (ans < arr[i] - arr[i - 1] - 1)
			ans = arr[i] - arr[i - 1] - 1;
	}

	int h = ans / 60, m = ans % 60;
	printf("%d%c%d", h, ':', m);

	return 0;
}


import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main()
{
    uint n, k, le;
    readf( "%s %s %s", &n, &k, &le );
    readln;
    auto a = readln.split.map!(to!int).array;
    a.sort();

    auto overLimit = Array!uint();
    ulong ans = 0;
    for ( int i = 0; i < n*k; i += k ) {
        ans += a[ i ];
        if ( a[ 0 ] + le < a[ i ] ) overLimit ~= a[ i ];
        debug { writeln(i); }
    }

    auto candidates = Array!uint();
    for ( int i = 0; i < n*k && a[ i ] <= a[ 0 ] + le; ++i ) {
        if ( i % k == 0 ) continue;

        candidates ~= a[ i ];
    }

    debug { writeln(a); writeln(ans); writeln(overLimit.array); writeln(candidates.array); }

    while ( !overLimit.empty() ) {
        if ( candidates.empty() ) {
            writeln( 0 );
            return;
        }

        ans -= overLimit.back - candidates.back;
        overLimit.removeBack();
        candidates.removeBack();
    }

    writeln ( ans );
}

import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;
import std.numeric;
import std.bigint;

void main()
{
	int n, k, l;
	readln.chomp.split.tie(n, k, l);
	long[] a = readln.chomp.split.map!(to!long).array;
	alias Tree = RedBlackTree!(long, "a < b", true);
	Tree left = new Tree();
	Tree right = new Tree();
	long target = a.reduce!min;
	foreach (i, v; a) {
		if (v <= target + l) {
			left.insert(v);
		} else {
			right.insert(v);
		}
	}
	debug verbose(left);
	debug verbose(right);
	bool ok = true;
	long sum = 0;
	while (right.length) {
		if (left.length == 0) {
			ok = false;
			break;
		}
		int t = 0;
		for (;t < k - 1 && right.length > 0;) {
			right.removeBack;
			++t;
		}
		long v = left.back;
		for (;t < k && left.length > 0;) {
			v = left.back;
			left.removeBack;
			++t;
		}
		if (t < k) {
			ok = false;
			break;
		}
		sum += v;
	}
	while (left.length) {
		int t = 0;
		long v = left.back;
		for (;t < k && left.length > 0;) {
			v = left.back;
			left.removeBack;
			++t;
		}
		if (t < k) {
			ok = false;
			break;
		}
		sum += v;
	}
	if (ok) {
		sum.writeln;
	} else {
		0.writeln;
	}
}

void tie(R, Args...)(R arr, ref Args args)
		if (isRandomAccessRange!R || isArray!R)
in
{
	assert (arr.length == args.length);
}
body
{
	foreach (i, ref v; args) {
		alias T = typeof(v);
		v = arr[i].to!T;
	}
}

void verbose(Args...)(in Args args)
{
	stderr.write("[");
	foreach (i, ref v; args) {
		if (i) stderr.write(", ");
		stderr.write(v);
	}
	stderr.writeln("]");
}


import std.algorithm;
import std.container.array;
import std.conv;
import std.range;
import std.stdio;

void main() {
    int n;
    readf("%d ", &n);
    auto a = readln().split().map!(to!int)().array();
    int[int] d, first, last;
    foreach (i, x; a) {
        d[x]++;
        if (x !in first)
            first[x] = i;
        last[x] = i;
    }
    Array!int keys;
    int result = 0;
    foreach (k, v; d)
        if (v > result) {
            keys.clear();
            keys ~= k;
            result = v;
        } else if (v == result)
            keys ~= k;
    int resX, resY;
    result = n;
    foreach (k; keys) {
        int x = first[k], y = last[k];
        if (y - x < result) {
            resX = x;
            resY = y;
            result = y - x;
        }
    }
    writeln(resX + 1, ' ', resY + 1);
}

import std.stdio;
import std.c.stdio;
import std.math;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.typecons;

void main() {
  int n = readln().strip().to!int;
  int[] a = readln().split().map!(to!int).array;
  int[int] l, r, ct;
  foreach(int i, v; a) {
    if (v in l) {
      l[v] = min(l[v] ,i);
      r[v] = max(r[v] ,i);
      ct[v]++;
    } else {
      l[v] = i;
      r[v] = i;
      ct[v] = 1;
    }
  }
  int[] max_ks;
  int max_v = 0;
  foreach(k, v; ct) {
    if (max_v < v) {
      max_ks.length = 0;
      max_v = v;
    }
    if (max_v == v) {
      max_ks ~= k;
    }
  }
  int min_len = n + 1, min_k;
  foreach(k; max_ks) {
    if (r[k] - l[k] + 1 < min_len) {
      min_len = r[k] - l[k] + 1;
      min_k = k;
    }
  }
  writeln(l[min_k] + 1, ' ', r[min_k] + 1);
}


import std.stdio;
import std.c.stdio;
import std.math;
import std.algorithm;
import std.conv;
import std.string;
import std.array;

void main() {
  int n, w ;
  scanf("%d %d\n", &n, &w);
  int[] a = readln().split().map!(to!int).array;
  a.sort();
  real cap = min(real(a[0]), a[n] / 2.0);
  writefln("%.10f", min(real(w), cap * n + 2 * cap * n));
}

import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.range;

void main() {
    int n, w;
    readf("%d %d\n", &n, &w);

    int[] a = readln.chomp.split.map!(to!int).array.sort;

    int woman_min = a[0];
    int man_min = a[n];

    double base = 0.0;
    if (woman_min * 2 > man_min) {
        base = man_min / 2.0;
    } else {
        base = cast(double)woman_min;
    }

    double whole = base * 3 * n;

    if (whole <= w) {
        writefln("%.10f", base * 3 * n);
    } else {
        writeln(w);
    }
}


module main;

import std.c.stdio;

int main(string[] argv)
{
    int n, l, r;
    scanf("%d %d %d", &n, &l, &r);
    l = l - 1; r = r - 1;
    int [] a = new int[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int [] b = new int[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &b[i]);
    int ok = 0;
    for (int i = 0; i < n; i++)
        if ((i < l || i > r) && a[i] != b[i])
            ok = ok + 1;
    if (ok == 0)
        printf("TRUTH");
    else
        printf("LIE");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,l,r;
	scanf("%d %d %d", &n, &l,&r);
	int [] arr = new int[n];
	int [] arr2 =new int[n];
	int[]  arr3 = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++)
		scanf("%d", &arr3[i]);
	int q;
	bool ok=0;
	for(int i = 0; i<l-1; i++)
	    if(arr3[i]!=arr[i])
	    {
	        printf("LIE");
	        return 0;
	    }
    for(int i = r; i<n; i++)
	    if(arr3[i]!=arr[i])
	    {
	        printf("LIE");
	        return 0;
	    }

	printf("TRUTH");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,l,r, y = 0;
	scanf("%d %d %d", &n, &l, &r);
	l--;
	r--;
	int [] arr = new int[n];
	int [] arr2 = new int[n];
	int [] arr3 = new int[n];
	int [] arr4 = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++)
	    scanf("%d", &arr2[i]);
	int q;
	for(int i = 0; i<n; i++)
		if((i < l || i > r) && arr[i] != arr2[i]) y = 1;
	for(int i = 0; i<n; i++)
	    if(i >= l && i <= r) arr3[arr[i]]++, arr4[arr2[i]]++;
	for(int i = 0; i<n; i++)
	    if(arr3[i] != arr4[i]) y = 1;
	if (y == 1) printf("LIE");
	else printf("TRUTH");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,l,r;
	scanf("%d %d %d", &n, &l, &r);
	l--;
	r--;
	int [] arr = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	int q;
	for(int i = 0; i<n; i++)
	{
	    scanf("%d", &q);
	    if(q != arr[i] && (i < l || i > r))
	    {
	        printf("LIE");
	        return 0;
	    }
	}
	printf("TRUTH");
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

int main(string[] argv) {
	int n, L, R;
	scanf("%d %d %d", &n, &L, &R);

	int [] arr = new int[1 + n];
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr[i]);
	int [] arr2 = new int[1 + n];
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr2[i]);

	int len = R - L + 1;
	int [] a = new int[len];
	int [] b = new int[len];

	int j = 0;
	for (int i = L; i <= R; ++i) {
		a[j] = arr[i];
		b[j] = arr2[i];
		j++;
	}

	sort(a);
	sort(b);

	int q = 1;
	for (int i = 0; i < len; ++i) {
		if (a[i] != b[i]) {
			q = 0;
		}
	}

	for (int i = 1; i <= L - 1; ++i) {
		if (arr[i] != arr2[i]) {
			q = 0;
		}
	}

	for (int i = R + 1; i <= n; ++i) {
		if (arr[i] != arr2[i]) {
			q = 0;
		}
	}

	if (q == 1)
		printf("TRUTH");
	else
		printf("LIE");

	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,l,r;
	scanf("%d %d %d", &n, &l, &r);
	int [] current = new int[n];
	int [] was = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &was[i]);
	for(int i = 0; i<n; i++)
		scanf("%d", &current[i]);
	bool outside = true;
	for(int i = 0; i<l - 1; i++){
	    outside &= (was[i] == current[i]);
    }
	for(int i = r; i<n; i++){
	    outside &= (was[i] == current[i]);
	}
	bool inside = true;
	int [] counts = new int[n];
	for(int i = l - 1; i<r; i++){
	    counts[was[i]]++;
	    counts[current[i]]--;
	}
	int cnt = 0;
	for(int i = 0; i<n; i++){
	    inside &= (counts[i] == 0);
	}
	if (inside && outside)
	    printf("TRUTH");
	else
	    printf("LIE");
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm.sorting;

int main(string[] argv)
{
	int n,l,r;
	bool flag;
	flag = 1;
	scanf("%d %d %d", &n, &l, &r);
	int [] a = new int[n];
	int [] b = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &a[i]);
	for(int i = 0; i<n; i++)
		scanf("%d", &b[i]);
	for(int i = 0; i<l - 1; i++)
	    if (flag && a[i] != b[i])
	        flag = 0;
	for(int i = r; i<n; i++)
	    if (flag && a[i] != b[i])
	        flag = 0;
    a.sort();
    b.sort();
	for(int i = 0; i<n; i++)
	    if (flag && a[i] != b[i])
	        flag = 0;
    if (flag)
        printf("TRUTH");
    else
        printf("LIE");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,l, r;
	scanf("%d %d %d", &n, &l, &r);
	int [] arr = new int[n];
	l = l - 1;
	r = r - 1;
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	bool ans = true;
	int j;
	for (int i = 0; i < n; i++) {
	    scanf("%d", &j);
	    if (i < l || i > r)
	        if (j != arr[i])
	            ans = false;
	}
	if (ans) printf("TRUTH");
	else printf("LIE");
	return 0;
}

import std.stdio : writeln, stdin;

import std.c.stdio;

int[] a = new int[111111];

void main()
{
    int n, l, r;
    scanf("%d", &n);
    scanf("%d", &l);
    scanf("%d", &r);
    int i;
    for (i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    int x;
    for (i = 0; i < n; ++i) {
        scanf("%d", &x);
        if ((i + 1 >= l) && (i + 1 <= r)) {
            continue;
        }
        if (a[i] != x) {
            writeln("LIE");
            return;
        }
    }
    writeln("TRUTH");
}

module main;

import std.stdio : writeln, stdin;
import core.stdc.stdio;

int main(string[] argv)
{
	int n, l, r;
	scanf("%d %d %d", &n, &l, &r);
	l = l - 1;
	r = r - 1;
	int [] arr = new int[n];
	int [] b = new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	for (int i = 0; i < n; i++)
	    scanf("%d", &b[i]);
	for (int i = 0; i < l; i++) {
	    if (arr[i] != b[i]) {
	        writeln("LIE");
	        return 0;
	    }
	}
	for (int i = r + 1; i < n; i++) {
    	if (arr[i] != b[i]) {
    	        writeln("LIE");
    	        return 0;
    	    }
    }
	writeln("TRUTH");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,l,r;
	scanf("%d %d %d", &n, &l, &r);
	int [] arr = new int[n];
	int [] arr2 = new int[n];
	int [] mk = new int[n+1];
	for(int i = 0; i<n; i++) scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++) scanf("%d", &arr2[i]);
// 	for(int i = 0; i<n; i++) printf("%d ", arr[i]);
	for(int i = 0; i <= n; i++) mk[i] = 0;
	for(int i = l; i <= r; i++){
	    mk[arr[i-1]]++;
	    mk[arr2[i-1]]--;
	}
	for(int e = 0; e <=n; e++){
	    if(mk[e] != 0){
	        printf("LIE\n");
	        return 0;
	   }
	  }
	for(int e = 0; e < n; e++){
	    if(l <= e+1 && e+1 <= r) continue;
	    if(arr[e] != arr2[e]){
	        printf("LIE\n");
	        return 0;
	    }
	}
	  printf("TRUTH\n");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int[] vasha = new int[a+1];
    int[] vashab = new int[a+1];
    for(int i = 1; i <= a; i++)
    {
        scanf("%d",&vasha[i]);
    }
    for(int i = 1; i <= a; i++)
    {
        scanf("%d",&vashab[i]);
    }

    for(int i = 1; i <= a; i++)
    {
        if(i<b||i>c){
            if(vasha[i]!=vashab[i]){
                printf("LIE");
                return 0;
            }
        }
    }

    printf("TRUTH");
    return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,l,r;
	scanf("%d %d %d", &n, &l,&r);
	l-=1;
	r-=1;
	int [] arr = new int[n];
	int [] arr2=new int[n];
	for(int i = 0; i<n; i++)
		scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++)
		scanf("%d", &arr2[i]);
	for(int i=0;i<n;i++){
	    if(i<l || i>r){
	        if(arr[i]!=arr2[i]){
	            printf("LIE");
	            return 0;
	        }
	    }
	}
	printf("TRUTH");
	return 0;
}

import std.stdio;

int main() {
  int a[123456];
  int b[123456];
  int n, l, r;
  readf(" %d %d %d", &n, &l, &r);
  for (int i = 1; i <= n; i++) {
    readf(" %d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    readf(" %d", &b[i]);
  }
  int ans = 0;
  for (int i = 1; i < l; i++) {
    if (a[i] != b[i]) {
      ans = 1;
    }
  }
  for (int i = r + 1; i <= n; i++) {
    if (a[i] != b[i]) {
      ans = 1;
    }
  }
  if (ans) {
    writeln("LIE");
  } else {
    writeln("TRUTH");
  }
  return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,l,r;
	scanf("%d %d %d", &n, &l, &r);
	int [] a = new int[n+5];
	int [] b = new int[n+5];
	int [] f = new int[n+5];
	for(int i = 1; i<=n; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i<=n; i++)
		scanf("%d", &b[i]);
	for (int i=1; i<l; i++) {
	    if (a[i]!=b[i]) {
	    printf("LIE\n");
	    return 0;
	    }
	}
	for (int i=r+1; i<=n; i++) {
	    if (a[i]!=b[i]) {
	    printf("LIE\n");
	    return 0;
	    }
	}
	for (int i=l; i<=r; i++) f[a[i]]++;
	for (int i=l; i<=r; i++) f[b[i]]--;
	for (int i=1; i<=n; i++) if (f[i]!=0) {
	printf("LIE\n");
	return 0;
	}
	printf("TRUTH\n");
	return 0;
}

module main;

import std.c.stdio;
import std.algorithm.sorting;

int main(string[] argv)
{
  int n, l, r;
  scanf("%d %d %d", &n, &l, &r);
  int [] a = new int[n];
  int [] b = new int[n];
  int [] aa = new int[r-l+1];
  int [] bb = new int[r-l+1];
  for(int i = 0; i<n; i++)
    scanf("%d", &a[i]);
  for(int i = 0; i<n; i++)
    scanf("%d", &b[i]);
  bool ok = 1;
  for (int i = 0; i < l-1; i++)
    if (a[i] != b[i])
      ok = 0;
  for (int i = r; i < n; i++)
    if (a[i] != b[i])
      ok = 0;
  for (int i = l; i <= r; i++) {
    aa[i-l] = a[i-1];
    bb[i-l] = b[i-1];
  }
  aa.sort();
  bb.sort();
  for (int i = 0; i < r-l+1; i++)
    if (aa[i] != bb[i])
      ok = 0;
  if (ok)
    printf("TRUTH");
  else
    printf("LIE");
  return 0;
}

import std.stdio;
int a[4000000];
int b[4000000];

int n, l, r;
int main() {
	readf("%s %s %s\n", &n, &l, &r);
	for (int i = 1; i < n; i++) readf("%s ", &a[i]);
	readf("%s\n", &a[n]);
	for (int i = 1; i < n; i++) readf("%s ", &b[i]);
	readf("%s", &b[n]);

	for (int i = 1;i <= l - 1; i++) if (a[i] != b[i]) {
		write("LIE");
		return 0;
	}
	for (int i = r + 1; i <= n; i++) if (a[i] != b[i]) {
		write("LIE");
		return 0;
	}
	write("TRUTH");

	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
    int n,l,r;
    scanf("%d%d%d",&n,&l,&r);
    l--;r--;
    int [] a = new int[n];
    for (int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int [] b = new int[n];
    for (int i=0;i<n;i++)
        scanf("%d",&b[i]);
    int [] m = new int[n+1];
    for (int i=l;i<=r;i++){
        m[a[i]]++;
        m[b[i]]--;
    }
    for (int i=0;i<=n;i++){
        if (m[i]!=0){
            printf("LIE");
            return 0;
        }
    }
    for (int i=0;i<l;i++){
        if (a[i]!=b[i]){
            printf("LIE");
            return 0;
        }
    }
    for (int i=r+1;i<n;i++){
        if (a[i]!=b[i]){
            printf("LIE");
            return 0;
        }
    }
    printf("TRUTH");
	return 0;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;

int main(string[] argv)
{
	int n, l, r;
	bool ans = true;

	scanf("%d%d%d", &n, &l, &r);
	int [] a = new int[n];
	int [] b = new int[n];
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) scanf("%d", &b[i]);
	a[l-1..r].sort();
	b[l-1..r].sort();
	for(int i = 0; i < n; i++) if(a[i] != b[i]) ans = false;

	if(ans)
	    printf("TRUTH");
	else
	    printf("LIE");

	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

int main(string[] argv) {
	int n, L, R;
	scanf("%d %d %d", &n, &L, &R);

	int [] arr = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &arr[i]);
	int [] arr2 = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &arr2[i]);

	int len = R - L + 1;
	int [] a = new int[len];
	int [] b = new int[len];

	int j = 0;
	for (int i = L - 1; i < R; ++i) {
		a[j] = arr[i];
		b[j] = arr2[i];
		j++;
	}

	sort(a);
	sort(b);

	int q = 1;
	for (int i = 0; i < len; ++i) {
		if (a[i] != b[i]) {
			q = 0;
		}
	}

	if (q == 1)
		printf("TRUTH");
	else
		printf("LIE");

	return 0;
}

module main;

import std.c.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

int main(string[] argv) {
	int n, L, R;
	scanf("%d %d %d", &n, &L, &R);

	int [] arr = new int[1 + n];
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr[i]);
	int [] arr2 = new int[1 + n];
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr2[i]);

	int len = R - L + 1;
	int [] a = new int[len];
	int [] b = new int[len];

	int j = 0;
	for (int i = L; i <= R; ++i) {
		a[j] = arr[i];
		b[j] = arr2[i];
		j++;
	}

	sort(a);
	sort(b);

	int q = 1;
	for (int i = 0; i < len; ++i) {
		if (a[i] != b[i]) {
			q = 0;
		}
	}

	for (int i = 1; i < L; ++i) {
		if (a[i] != b[i]) {
			q = 0;
		}
	}

	for (int i = R + 1; i <= n; ++i) {
		if (a[i] != b[i]) {
			q = 0;
		}
	}

	if (q == 1)
		printf("TRUTH");
	else
		printf("LIE");

	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,l,r;
	scanf("%d %d", &n, &l, &r);
	int [] arr = new int[n];
	int [] arr2 = new int[n];
	int [] mk = new int[n+1];
	for(int i = 0; i<n; i++) scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++) scanf("%d", &arr2[i]);
	for(int i = l; i <= r; i++){
	    mk[arr[i-1]]++;
	    mk[arr2[i-1]]--;
	}
	for(int e = 0; e <=n; e++){
	    if(mk[e] != 0){
	        printf("LIE\n");
	        return 0;
	   }
	  }
	  printf("TRUTH\n");
	return 0;
}

module main;

import std.c.stdio;

int main(string[] argv)
{
	int n,k,l,r;
	scanf("%d %d %d", &n, &l, &r);
	int [] arr = new int[n];
	int [] arr2 = new int[n];
	int [] mk = new int[n+1];
	for(int i = 0; i<n; i++) scanf("%d", &arr[i]);
	for(int i = 0; i<n; i++) scanf("%d", &arr2[i]);
// 	for(int i = 0; i<n; i++) printf("%d ", arr[i]);
	for(int i = 0; i <= n; i++) mk[i] = 0;
	for(int i = l; i <= r; i++){
	    mk[arr[i-1]]++;
	    mk[arr2[i-1]]--;
	}
	for(int e = 0; e <=n; e++){
	    if(mk[e] != 0){
	        printf("LIE\n");
	        return 0;
	   }
	  }
	  printf("TRUTH\n");
	return 0;
}

module main;

import core.stdc.stdio;
import std.algorithm.sorting;

int main(string[] argv)
{
	int n, l, r;
	bool ans = true;

	scanf("%d%d%d", &n, &l, &r);
	int [] a = new int[r - l + 1];
	int [] b = new int[r - l + 1];
	for(int i = 1; i <= n; i++)
	{
	    int t;
		scanf("%d", &t);
		if(i < l || i > r) continue;
		a[i - l] = t;
	}
	for(int i = 1; i <= n; i++)
	{
	    int t;
		scanf("%d", &t);
		if(i < l || i > r) continue;
		b[i - l] = t;
	}
	a.sort();
	b.sort();
	for(int i = 0; i < r - l + 1; i++)
	if(a[i] != b[i]) ans = false;

	if(ans)
	    printf("TRUTH");
	else
	    printf("LIE");

	return 0;
}