Consider the set of all nonnegative integers: $$${0, 1, 2, \dots}$$$. Given two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^4$$$). We paint all the numbers in increasing number first we paint $$$0$$$, then we paint $$$1$$$, then $$$2$$$ and so on.Each number is painted white or black. We paint a number $$$i$$$ according to the following rules:    if $$$i = 0$$$, it is colored white;   if $$$i \ge a$$$ and $$$i - a$$$ is colored white, $$$i$$$ is also colored white;   if $$$i \ge b$$$ and $$$i - b$$$ is colored white, $$$i$$$ is also colored white;   if $$$i$$$ is still not colored white, it is colored black. In this way, each nonnegative integer gets one of two colors.For example, if $$$a=3$$$, $$$b=5$$$, then the colors of the numbers (in the order from $$$0$$$) are: white ($$$0$$$), black ($$$1$$$), black ($$$2$$$), white ($$$3$$$), black ($$$4$$$), white ($$$5$$$), white ($$$6$$$), black ($$$7$$$), white ($$$8$$$), white ($$$9$$$), ...Note that:    It is possible that there are infinitely many nonnegative integers colored black. For example, if $$$a = 10$$$ and $$$b = 10$$$, then only $$$0, 10, 20, 30$$$ and any other nonnegative integers that end in $$$0$$$ when written in base 10 are white. The other integers are colored black.   It is also possible that there are only finitely many nonnegative integers colored black. For example, when $$$a = 1$$$ and $$$b = 10$$$, then there is no nonnegative integer colored black at all. Your task is to determine whether or not the number of nonnegative integers colored black is infinite.If there are infinitely many nonnegative integers colored black, simply print a line containing "Infinite" (without the quotes). Otherwise, print "Finite" (without the quotes).

The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then $$$t$$$ lines follow, each line contains two space-separated integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^4$$$).

For each test case, print one line containing either "Infinite" or "Finite" (without the quotes). Output is case-insensitive (i.e. "infinite", "inFiNite" or "finiTE" are all valid answers).

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, core.stdc.stdlib;

void main() {
    auto T = readln.chomp.to!int;
    while (T--) {
        auto s = readln.split.map!(to!int);
        auto A = s[0];
        auto B = s[1];
        writeln(gcd(A, B) == 1 ? "Finite" : "Infinite");
    }
}

//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.numeric;

class InputReader {
  private:
  ubyte[] p;
  ubyte[] buffer;
  size_t cur;
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
    p = stdin.rawRead (buffer);
  }
  final ubyte skipByte (ubyte lo) {
    while (true) {
      auto a = p[cur .. $];
      auto r = a.find! (c => c >= lo);
      if (!r.empty) {
        cur += a.length - r.length;
        return p[cur++];
      }
      p = stdin.rawRead (buffer);
      cur = 0;
      if (p.empty) return 0;
    }
  }
  final ubyte nextByte () {
    if (cur < p.length) {
       return p[cur++];
    }
    p = stdin.rawRead (buffer);
    if (p.empty) return 0;
    cur = 1;
    return p[0];
  }

  template next(T) if (isSigned!T) {
    final T next ()  {
      T res;
      ubyte b = skipByte (45);
      if (b == 45) {
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    final T next () {
      T res = skipByte (48) - 48;
      while (true) {
        ubyte b = nextByte ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  final T[] nextA(T) (int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

void main() {
  auto r = new InputReader;
  foreach (t; 0 .. r.next!uint) {
    auto a = r.next!uint;
    auto b = r.next!uint;
    writeln (gcd (a, b) == 1 ? "Finite" : "Infinite");
  }
}

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

string FMT_F = "%.10f";

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; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
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; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto t = RD!int;
	auto ans = new bool[](t);
	foreach (i; 0..t)
	{
		auto a = RD!int;
		auto b = RD!int;
		auto x = min(a, b);
		auto y = cast(long)max(a, b);
		auto arr = new bool[](x);
		foreach (j; 1..10^^5)
		{
			auto z = (y*j) % x;
			arr[cast(int)z] = true;
		}

		bool ok = true;
		foreach (j; 0..arr.length)
		{
			if (arr[j] == false)
			{
				ok = false;
				break;
			}
		}
		ans[i] = ok;
	}

	foreach (e; ans)
	{
		writeln(e ? "Finite" : "Infinite");
	}
	stdout.flush();
	debug readln();
}

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

string FMT_F = "%.10f";

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; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
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; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto t = RD!int;
	auto ans = new bool[](t);
	foreach (i; 0..t)
	{
		auto a = RD!int;
		auto b = RD!int;
		int[] open = [0];
		auto limit = (10^^6)+1;
		auto close = new bool[](limit);
		close[0] = true;
		while (!open.empty)
		{
			auto n = open.front; open.popFront;
			auto na = (n+a);
			auto nb = (n+b);
			if (na < limit) if (close[na] == false)
			{
				close[na] = true;
				open ~= na;
			}
			if (nb < limit) if (close[nb] == false)
			{
				close[nb] = true;
				open ~= nb;
			}
		}
		bool ok = true;
		foreach (j; close.length-min(a,b)..close.length)
		{
			if (close[j] == false)
			{
				ok = false;
				break;
			}
		}
		ans[i] = ok;
	}

	foreach (e; ans)
	{
		writeln(e ? "Finite" : "Infinite");
	}
	stdout.flush();
	debug readln();
}

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

string FMT_F = "%.10f";

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; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
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; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto t = RD!int;
	auto ans = new bool[](t);
	foreach (i; 0..t)
	{
		auto a = RD!int;
		auto b = RD!int;
		int[] open = [0];
		auto limit = (10^^4)+1;
		auto close = new bool[](limit);
		close[0] = true;
		while (!open.empty)
		{
			auto n = open.front; open.popFront;
			auto na = (n+a);
			auto nb = (n+b);
			if (na < limit) if (close[na] == false)
			{
				close[na] = true;
				open ~= na;
			}
			if (nb < limit) if (close[nb] == false)
			{
				close[nb] = true;
				open ~= nb;
			}
		}
		bool ok = true;
		foreach (j; close.length-min(a,b)..close.length)
		{
			if (close[j] == false)
			{
				ok = false;
				break;
			}
		}
		ans[i] = ok;
	}

	foreach (e; ans)
	{
		writeln(e ? "Finite" : "Infinite");
	}
	stdout.flush();
	debug readln();
}

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

string FMT_F = "%.10f";

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; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
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; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto t = RD!int;
	auto ans = new bool[](t);
	foreach (i; 0..t)
	{
		auto a = RD!int;
		auto b = RD!int;
		int[] open = [0];
		auto limit = (10^^4)+1;
		auto close = new bool[](limit);
		close[0] = true;
		while (!open.empty)
		{
			auto n = open.front; open.popFront;
			auto na = (n+a);
			auto nb = (n+b);
			if (na < limit) if (close[na] == false)
			{
				close[na] = true;
				open ~= na;
			}
			if (nb < limit) if (close[nb] == false)
			{
				close[nb] = true;
				open ~= nb;
			}
		}
		bool ok = true;
		foreach (j; close.length-max(a,b)..close.length)
		{
			if (close[j] == false)
			{
				ok = false;
				break;
			}
		}
		ans[i] = ok;
	}

	foreach (e; ans)
	{
		writeln(e ? "Finite" : "Infinite");
	}
	stdout.flush();
	debug readln();
}


PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of $$$6$$$ slices, medium ones consist of $$$8$$$ slices, and large pizzas consist of $$$10$$$ slices each. Baking them takes $$$15$$$, $$$20$$$ and $$$25$$$ minutes, respectively.Petya's birthday is today, and $$$n$$$ of his friends will come, so he decided to make an order from his favorite pizzeria. Petya wants to order so much pizza that each of his friends gets at least one slice of pizza. The cooking time of the order is the total baking time of all the pizzas in the order.Your task is to determine the minimum number of minutes that is needed to make pizzas containing at least $$$n$$$ slices in total. For example:   if $$$12$$$ friends come to Petya's birthday, he has to order pizzas containing at least $$$12$$$ slices in total. He can order two small pizzas, containing exactly $$$12$$$ slices, and the time to bake them is $$$30$$$ minutes;  if $$$15$$$ friends come to Petya's birthday, he has to order pizzas containing at least $$$15$$$ slices in total. He can order a small pizza and a large pizza, containing $$$16$$$ slices, and the time to bake them is $$$40$$$ minutes;  if $$$300$$$ friends come to Petya's birthday, he has to order pizzas containing at least $$$300$$$ slices in total. He can order $$$15$$$ small pizzas, $$$10$$$ medium pizzas and $$$13$$$ large pizzas, in total they contain $$$15 \cdot 6 + 10 \cdot 8 + 13 \cdot 10 = 300$$$ slices, and the total time to bake them is $$$15 \cdot 15 + 10 \cdot 20 + 13 \cdot 25 = 750$$$ minutes;  if only one friend comes to Petya's birthday, he can order a small pizza, and the time to bake it is $$$15$$$ minutes.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. Each testcase consists of a single line that contains a single integer $$$n$$$ ($$$1 \le n \le 10^{16}$$$) — the number of Petya's friends.

For each testcase, print one integer — the minimum number of minutes that is needed to bake pizzas containing at least $$$n$$$ slices in total.

// Vicfred
// https://codeforces.com/contest/1555/problem/A
// basic math
import std.algorithm;
import std.stdio;

void main() {
    long t;
    readf("%s\n", &t);

while(t--) {
    long n;
    readf("%s\n", &n);
    long ans = max(6L, n + 1L) / 2L * 5L;
    ans.writeln;
}
}

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

void main()
{
	int t = readInt!int; while (t--) solve;
}
void solve()
{
	long n = readInt!long;
	if (n <= 6)
	{
		return 15.writeln;
	}
	n += n % 2;
	((n/2)*5).writeln;
}

/* 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);
	}
}

// Cheese-Cracker: cheese-cracker.github.io

void theCode(){
    ll n = scan;
    ll tim = (n / 2) * 5;
    if(n % 2 != 0) tim += 5;
    tim = max(tim, 15);
    writeln(tim);
}

void main(){
    long tests = scan;        // Toggle!
    while(tests--) theCode();
}

/*********  That's All Folks!  *********/
import std.stdio, std.random, std.functional, std.container, std.algorithm;
import std.numeric, std.range, std.typecons, std.string, std.math, std.conv;
string[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}
T[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }
void show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, "| ");} stderr.writeln; } }
alias ll = long, tup = Tuple!(long, "x",  long, "y");

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

void main()
{
  long t;
  readf!" %d "(t);
  while (t--) {
    long n;
    readf!" %d "(n);
    n = (n + 1) / 2;
    if (n < 3)
      n = 3;
    writeln(n * 5);
  }
}


Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all customers by controlling the temperature of the restaurant.The restaurant has an air conditioner that has 3 states: off, heating, and cooling. When it's off, the restaurant's temperature remains the same. When it's heating, the temperature increases by 1 in one minute. Lastly, when it's cooling, the temperature decreases by 1 in one minute. Gildong can change the state as many times as he wants, at any integer minutes. The air conditioner is off initially.Each customer is characterized by three values: $$$t_i$$$ — the time (in minutes) when the $$$i$$$-th customer visits the restaurant, $$$l_i$$$ — the lower bound of their preferred temperature range, and $$$h_i$$$ — the upper bound of their preferred temperature range.A customer is satisfied if the temperature is within the preferred range at the instant they visit the restaurant. Formally, the $$$i$$$-th customer is satisfied if and only if the temperature is between $$$l_i$$$ and $$$h_i$$$ (inclusive) in the $$$t_i$$$-th minute.Given the initial temperature, the list of reserved customers' visit times and their preferred temperature ranges, you're going to help him find if it's possible to satisfy all customers.

Each test contains one or more test cases. The first line contains the number of test cases $$$q$$$ ($$$1 \le q \le 500$$$). Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100$$$, $$$-10^9 \le m \le 10^9$$$), where $$$n$$$ is the number of reserved customers and $$$m$$$ is the initial temperature of the restaurant. Next, $$$n$$$ lines follow. The $$$i$$$-th line of them contains three integers $$$t_i$$$, $$$l_i$$$, and $$$h_i$$$ ($$$1 \le t_i \le 10^9$$$, $$$-10^9 \le l_i \le h_i \le 10^9$$$), where $$$t_i$$$ is the time when the $$$i$$$-th customer visits, $$$l_i$$$ is the lower bound of their preferred temperature range, and $$$h_i$$$ is the upper bound of their preferred temperature range. The preferred temperature ranges are inclusive. The customers are given in non-decreasing order of their visit time, and the current time is $$$0$$$.

For each test case, print "YES" if it is possible to satisfy all customers. Otherwise, print "NO". You can print each letter in any case (upper or lower).

NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way:  At $$$0$$$-th minute, change the state to heating (the temperature is 0).  At $$$2$$$-nd minute, change the state to off (the temperature is 2).  At $$$5$$$-th minute, change the state to heating (the temperature is 2, the $$$1$$$-st customer is satisfied).  At $$$6$$$-th minute, change the state to off (the temperature is 3).  At $$$7$$$-th minute, change the state to cooling (the temperature is 3, the $$$2$$$-nd customer is satisfied).  At $$$10$$$-th minute, the temperature will be 0, which satisfies the last customer. In the third case, Gildong can change the state to heating at $$$0$$$-th minute and leave it be. Then all customers will be satisfied. Note that the $$$1$$$-st customer's visit time equals the $$$2$$$-nd customer's visit time.In the second and the fourth case, Gildong has to make at least one customer unsatisfied.

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(){
	A: foreach(_; 0 .. rint){
		int n = rint;
		long m = rlong;
		S[] as;
		foreach(i; 0 .. n) as ~= S(rlong, rlong, rlong);
		// as is sorted.
		log("n:", n, "m:", m, "as:", as);

		long t = 0, l = m, r = m;
		foreach(a; as){
			log("t:", t, "l:", l, "r:", r);
			l = max(l - (a.t - t), a.l);
			r = min(r + (a.t - t), a.r);
			if(l > r){
				"NO".writeln;
				continue A;
			}
			t = a.t;
		}
		log("t:", t, "l:", l, "r:", r);
		"YES".writeln;
	}
}
struct S{
	long t, l, r;

}

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

struct Interval
{
  long l, h;

  bool empty()
  {
    return l > h;
  }
}

Interval intersect(Interval a, Interval b)
{
  return Interval(max(a.l, b.l), min(a.h, b.h));
}

struct Customer
{
  long t;
  Interval i;
}

alias type = multi;
struct TestCase
{
  mixin prettyPrinting;

  long n, m;
  @("n") Customer[] customers;

  void solve(long tc = -1)
  {
    if (tc == 1)
      logSym!(this);
    long lastTime = 0;
    Interval currentInterval = Interval(m, m);
    foreach(customer; customers)
      {
        with(customer)
          {
            auto elapsedTime = t - lastTime;
            currentInterval.l -= elapsedTime;
            currentInterval.h += elapsedTime;
            currentInterval = intersect(currentInterval, i);
            if (currentInterval.empty)
              break;
            lastTime = t;
          }
      }
    if (currentInterval.empty)
      {
        writeln("NO");
      }
    else
      {
        writeln("YES");
      }
  }
}

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 q = RD!int;
	auto ans = new bool[](q);
	foreach (qi; 0..q)
	{
		auto n = RD!int;
		auto m = RD;
		auto tlh = new long[][](n);
		foreach (i; 0..n)
		{
			tlh[i] = [RD, RD, RD];
		}

		bool ok = true;
		long t, h = m, l = m;
		foreach (i; 0..n)
		{
			auto d = tlh[i][0] - t;
			l = max(tlh[i][1], l-d);
			h = min(tlh[i][2], h+d);
			debug writeln("i:", i, " l:", l, " h:", h);
			if (l > tlh[i][2] || h < tlh[i][1])
			{
				ok = false;
				break;
			}
			t = tlh[i][0];
		}
		ans[qi] = ok;
	}
	foreach (e; ans)
		writeln(e ? "YES" : "NO");
	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(){
	A: foreach(_; 0 .. rint){
		int n = rint;
		long m = rlong;
		S[] as;
		foreach(i; 0 .. n) as ~= S(rlong, rlong, rlong);
		// as is sorted.

		long t = m, l = 0, r = 0;
		foreach(a; as){
			l = max(l - (a.t - t), a.l);
			r = min(r + (a.t - t), a.r);
			if(l > r){
				"NO".writeln;
				continue A;
			}
			t = a.t;
		}
		"YES".writeln;
	}
}
struct S{
	long t, l, r;

}

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(){
	A: foreach(_; 0 .. rint){
		int n = rint;
		long m = rlong;
		S[] as;
		foreach(i; 0 .. n) as ~= S(rlong, rlong, rlong);
		// as is sorted.

		long t = m, l = 0, r = 0;
		foreach(a; as){
			l = max(l - (a.t - t), a.l);
			r = min(r + (a.t - t), a.r);
			if(l > r){
				"NO".writeln;
				continue A;
			}
		}
		"YES".writeln;
	}
}
struct S{
	long t, l, r;
}


The new pedestrian zone in Moscow city center consists of $$$n$$$ squares connected with each other by $$$n - 1$$$ footpaths. We define a simple path as a sequence of squares such that no square appears in this sequence twice and any two adjacent squares in this sequence are directly connected with a footpath. The size of a simple path is the number of squares in it. The footpaths are designed in a such a way that there is exactly one simple path between any pair of different squares.During preparations for Moscow City Day the city council decided to renew ground tiles on all $$$n$$$ squares. There are $$$k$$$ tile types of different colors, numbered from $$$1$$$ to $$$k$$$. For each square exactly one tile type must be selected and then used to cover this square surface. To make walking through the city center more fascinating, it was decided to select tiles types for each square in such a way that any possible simple path of size exactly $$$k$$$ contains squares with all $$$k$$$ possible tile colors.You need to find out whether it is possible to place the tiles this way or not.

The first line contains two integers $$$n$$$, $$$k$$$ ($$$2 \le k \le n \le 200\,000$$$) — the number of squares in the new pedestrian zone, the number of different tile colors. Each of the following $$$n - 1$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ ($$$1 \le v_i, u_i \le n$$$) — numbers of the squares connected by the corresponding road. It's guaranteed, that it's possible to go from any square to any other square, moreover there is exactly one such simple path.

Print "Yes" if it is possible to assign tile colors this way and "No" otherwise. In case your answer is "Yes", print $$$n$$$ integers from $$$1$$$ to $$$k$$$ each, the color of the tile for every square.

NoteThe following pictures illustrate the pedestrian zone in first and second examples. The second picture also shows one possible distribution of colors among the squares for $$$k = 4$$$.

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        auto ds = new int[diamLen];
        foreach (j; 0 .. diamLen) {
          ds[j] = dfs(j, diam[j], -1)[0];
          if (ds[j] > 0) {
            if (j + 1 + ds[j] >= K && diamLen - j + ds[j] >= K) {
              ans = null;
              goto failed;
            }
          }
        }
        foreach (u; 0 .. N) {
          const j = rs[u];
          if (j + 1 >= diamLen - j) {
            ans[u] = (j + dep[u]) % K;
          } else {
            ans[u] = ((j - dep[u]) % K + K) % K;
          }
        }
       failed:
      }

      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        auto ds = new int[diamLen];
        foreach (j; 0 .. diamLen) {
          ds[j] = dfs(j, diam[j], -1)[0];
          if (j + 1 + ds[j] >= K && diamLen - j + ds[j] >= K) {
            ans = null;
            goto failed;
          }
        }
        foreach (u; 0 .. N) {
          const j = rs[u];
          if (j + 1 >= diamLen - j) {
            ans[u] = (j + dep[u]) % K;
          } else {
            ans[u] = ((j - dep[u]) % K + K) % K;
          }
        }
       failed:
      }

      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else if (diamLen < K) {
        ans[] = 0;
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        auto ds = new int[diamLen];
        foreach (j; 0 .. diamLen) {
          ds[j] = dfs(j, diam[j], -1)[0];
          if (j + 1 + ds[j] >= K && diamLen - j + ds[j] >= K) {
            ans = null;
            goto failed;
          }
        }
        foreach (u; 0 .. N) {
          const j = rs[u];
          if (j + 1 + ds[j] >= K) {
            ans[u] = (j + dep[u]) % K;
          } else {
            ans[u] = ((j - dep[u]) % K + K) % K;
          }
        }
       failed:
      }

      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else if (diamLen <= K) {
        ans[] = 0;
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        auto ds = new int[diamLen];
        foreach (j; 0 .. diamLen) {
          ds[j] = dfs(j, diam[j], -1)[0];
          if (j + 1 + ds[j] >= K && diamLen - j + ds[j] >= K) {
            ans = null;
            goto failed;
          }
        }
        foreach (u; 0 .. N) {
          const j = rs[u];
          if (j + 1 + ds[j] >= K) {
            ans[u] = (j + dep[u]) % K;
          } else {
            ans[u] = ((j - dep[u]) % K + K) % K;
          }
        }
       failed:
      }

      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else if (diamLen <= K) {
        ans[] = 0;
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        foreach (j; 0 .. diamLen) {
          ans[diam[j]] = j;
          const res = dfs(diam[j], diam[j], -1);
          if (max(j, diamLen - j) + 1 + res[0] > K) {
            ans = null;
            goto failed;
          }
        }
        foreach (u; 0 .. N) {
          ans[u] = (ans[rs[u]] + dep[u]) % K;
        }
       failed:
      }

      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        auto ds = new int[diamLen];
        foreach (j; 0 .. diamLen) {
          ds[j] = dfs(j, diam[j], -1)[0];
          if (j + 1 + ds[j] >= K && diamLen - j + ds[j] >= K) {
            ans = null;
            goto failed;
          }
        }
        foreach (u; 0 .. N) {
          const j = rs[u];
          if (j + 1 >= diamLen - j) {
            ans[u] = (j + dep[u]) % K;
          } else {
            ans[u] = ((j - dep[u]) % K + K) % K;
          }
        }
       failed:
      }

if(K==50011)writeln(diamLen);
      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}

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)); }

int N, K;
int[] A, B;

int[][] G;
bool[] on;
int[] rs, par, dep;

Tuple!(int, int) dfs(int r, int u, int p) {
  rs[u] = r;
  par[u] = p;
  dep[u] = (p == -1) ? 0 : (dep[p] + 1);
  auto ret = tuple(0, u);
  foreach (v; G[u]) {
    if (v != p && !on[v]) {
      auto res = dfs(r, v, u);
      chmax(ret, tuple(1 + res[0], res[1]));
    }
  }
  return ret;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      A = new int[N - 1];
      B = new int[N - 1];
      foreach (i; 0 .. N - 1) {
        A[i] = readInt() - 1;
        B[i] = readInt() - 1;
      }

      G = new int[][N];
      foreach (i; 0 .. N - 1) {
        G[A[i]] ~= B[i];
        G[B[i]] ~= A[i];
      }
      on = new bool[N];
      rs = new int[N];
      par = new int[N];
      dep = new int[N];
      const res0 = dfs(0, 0, -1);
      const res1 = dfs(res0[1], res0[1], -1);

      int[] diam;
      for (int u = res1[1]; u != -1; u = par[u]) {
        diam ~= u;
      }
      const diamLen = cast(int)(diam.length);
      debug {
        writeln("diam = ", diam);
      }

      auto ans = new int[N];
      if (K == 2) {
        dfs(0, 0, -1);
        ans = new int[N];
        foreach (u; 0 .. N) {
          ans[u] = dep[u] % 2;
        }
      } else {
        foreach (j; 0 .. diamLen) {
          on[diam[j]] = true;
        }
        auto ds = new int[diamLen];
        foreach (j; 0 .. diamLen) {
          ds[j] = dfs(j, diam[j], -1)[0];
          if (j + 1 + ds[j] >= K && diamLen - j + ds[j] >= K) {
            ans = null;
            goto failed;
          }
        }
        foreach (u; 0 .. N) {
          const j = rs[u];
          if (j + 1 + ds[j] >= K) {
            ans[u] = (j + dep[u]) % K;
          } else {
            ans[u] = ((j - dep[u]) % K + K) % K;
          }
        }
       failed:
      }

      if (ans) {
        writeln("Yes");
        foreach (u; 0 .. N) {
          if (u > 0) write(" ");
          write(ans[u] + 1);
        }
        writeln();
      } else {
        writeln("No");
      }
    }
  } catch (EOFException e) {
  }
}