On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The grasshopper wants to eat the insect.

Ostap knows that grasshopper is able to jump to any empty cell that is exactly k cells away from the current (to the left or to the right). Note that it doesn't matter whether intermediate cells are empty or not as the grasshopper makes a jump over them. For example, if k = 1 the grasshopper can jump to a neighboring cell only, and if k = 2 the grasshopper can jump over a single cell.

Your goal is to determine whether there is a sequence of jumps such that grasshopper will get from his initial position to the cell with an insect.


-----Input-----

The first line of the input contains two integers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ n - 1) — the number of cells in the line and the length of one grasshopper's jump.

The second line contains a string of length n consisting of characters '.', '#', 'G' and 'T'. Character '.' means that the corresponding cell is empty, character '#' means that the corresponding cell contains an obstacle and grasshopper can't jump there. Character 'G' means that the grasshopper starts at this position and, finally, 'T' means that the target insect is located at this cell. It's guaranteed that characters 'G' and 'T' appear in this line exactly once.


-----Output-----

If there exists a sequence of jumps (each jump of length k), such that the grasshopper can get from his initial position to the cell with the insect, print "YES" (without quotes) in the only line of the input. Otherwise, print "NO" (without quotes).


-----Examples-----
Input
5 2
#G#T#

Output
YES

Input
6 1
T....G

Output
YES

Input
7 3
T..#..G

Output
NO

Input
6 2
..GT..

Output
NO



-----Note-----

In the first sample, the grasshopper can make one jump to the right in order to get from cell 2 to cell 4.

In the second sample, the grasshopper is only able to jump to neighboring cells but the way to the insect is free — he can get there by jumping left 5 times.

In the third sample, the grasshopper can't make a single jump.

In the fourth sample, the grasshopper can only jump to the cells with odd indices, thus he won't be able to reach the insect.

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Implementation


Solutions:
class Node:

	def __init__(self, value='.', adj_list=None):
		if adj_list == None:
			self.adj_list = []
		else:
			self.adj_list = adj_list
		self.value = value
		self.scratch = 0

	def add_node(self, node):
		self.adj_list.append(node)

	def get_node(self, index):
		return self.adj_list[index]

	def dfs(self, k):
		visited = set()
		stack = []
		stack.append(self)
		self.scratch = 0
		found = False
		while len(stack) > 0:
			curr_node = stack.pop()
			curr_scratch = curr_node.scratch
			if curr_scratch == 0:
				if curr_node.value == '#':
					continue
				elif curr_node.value == 'T':
					stack.clear()
					found = True
					print('YES')
			if curr_node not in visited:
				visited.add(curr_node)
			new_scratch = (curr_scratch + 1) % k
			for node in curr_node.adj_list:
				node.scratch = new_scratch
				stack.append(node)
		if not found:
			print('NO')
nk_arr = input().split(' ')
n = int(nk_arr[0])
k = int(nk_arr[1])
line = input()
g_node = Node(value='G')
init_pos = line.index('G')
start_node = g_node
for i in range(init_pos + 1, len(line)):
	start_node.add_node(Node(value=line[i]))
	start_node = start_node.adj_list[-1]
start_node = g_node
for i in range(init_pos - 1, -1, -1):
	start_node.add_node(Node(value=line[i]))
	start_node = start_node.adj_list[-1]
g_node.dfs(k)


(n, k) = map(int, input().split())
S = input()
i = S.index('G')
p = S.index('T')
c = 0
if i < p:
	while i < p:
		i = i + k
		if i > p:
			c = 0
			break
		if S[i] == '#':
			c = 0
			break
		if S[i] == 'T':
			c = 1
			break
else:
	while i > p:
		i = i - k
		if i < p:
			c = 0
			break
		if S[i] == '#':
			c = 0
			break
		if S[i] == 'T':
			c = 1
			break
if c == 1 or p == i:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
arr = list(input())
starting = arr.index('G')
end = arr.index('T')
if end < starting:
	(starting, end) = (end, starting)
i = starting
broken = 0
while i <= end:
	if arr[i] == '#':
		broken += 1
		break
	i += k
if abs(starting - end) % k == 0 and broken == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = input()
z = a.index('G')
x = a.index('T')
if abs(z - x) % m != 0:
	print('NO')
else:
	q = 0
	for j in range(min(z, x), max(z, x) + 1, m):
		if a[j] == '#':
			q = 1
			break
	if q == 1:
		print('NO')
	else:
		print('YES')


def main():
	(n, k) = map(int, input().split())
	s = input()
	start = s.index('G')
	target = s.index('T')
	if start > target:
		(start, target) = (target, start)
	i = 1
	jumps = (target - start) // k
	valid = (target - start) % k == 0 and all((s[start + i * k] == '.' for i in range(1, jumps)))
	print('YES' if valid else 'NO')
main()


(n, k) = map(int, input().split())
s = input()
a = s.find('G')
b = s.find('T')
if a > b:
	(a, b) = (b, a)
print('YES' if (b - a) % k == 0 and all((s[i] != '#' for i in range(a, b, k))) else 'NO')


def solve():
	a = s.find('G')
	b = s.find('T')
	if a > b:
		(a, b) = (b, a)
	if (b - a) % k:
		return 'NO'
	for i in range(a + k, b, k):
		if s[i] != '.':
			return 'NO'
	return 'YES'
read = lambda : map(int, input().split())
(n, k) = read()
s = input()
print(solve())


(n, k) = map(int, input().split())
sequence = input()
index_G = sequence.find('G')
index_T = sequence.find('T')
flag = True
if index_T > index_G:
	for i in range(index_G, n, k):
		if i > index_T:
			flag = False
			print('NO')
			break
		elif i == index_T:
			flag = False
			print('YES')
			break
		elif sequence[i] == '#':
			flag = False
			print('NO')
			break
	if flag:
		print('NO')
flag = True
if index_T < index_G:
	for i in range(index_G, -1, -k):
		if i < index_T:
			flag = False
			print('NO')
			break
		elif i == index_T:
			flag = False
			print('YES')
			break
		elif sequence[i] == '#':
			flag = False
			print('NO')
			break
	if flag:
		print('NO')


(n, k) = list(map(int, input().split()))
s = input()
(x1, x2) = (s.find('G'), s.find('T'))
(x1, x2) = (min(x1, x2), max(x1, x2))
for i in range(x1, x2 + 1, k):
	if s[i] == '#':
		print('NO')
		exit()
if s[i] != s[x2]:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
flag = True
for i in range(min(s.index('G'), s.index('T')), max(s.index('G'), s.index('T')), k):
	if s[i] == '#':
		flag = False
print('YES' if abs(s.index('G') - s.index('T')) % k == 0 and flag else 'NO')


(n, k) = map(int, input().split())
z = input()
s = z.find('G')
e = z.find('T')
if e < s:
	z = z[::-1]
	s = z.find('G')
	e = z.find('T')
flag = 0
while s <= e:
	if z[s] == '#':
		print('NO')
		flag = 1
		break
	elif z[s] == 'T':
		print('YES')
		flag = 1
		break
	s += k
if flag == 0:
	print('NO')


(n, k) = map(int, input().split())
s = input().strip()
a = 0
b = 0
for i in range(len(s)):
	if s[i] == 'G':
		a = i
	if s[i] == 'T':
		b = i
if a > b:
	(a, b) = (b, a)
while a < b:
	if s[a] == '#':
		print('NO')
		exit()
	a += k
if a == b:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
if s.index('G') < s.index('T'):
	subset_s = s[s.index('G'):s.index('T') + 1]
else:
	subset_s = s[s.index('T'):s.index('G') + 1][::-1]
for i in range(0, len(subset_s), k):
	if subset_s[i] == '#':
		print('NO')
		break
	if subset_s[i] == 'T':
		print('YES')
		break
else:
	print('NO')


s = input().split()
n = int(s[0])
k = int(s[1])
mas = input()
startG = mas.index('G')
startT = mas.index('T')
if startG > startT:
	itt = -1
	step = -k
	start = startG - k
else:
	itt = n
	step = k
	start = startG + k
for i in range(start, itt, step):
	if mas[i] == '#':
		print('NO')
		break
	elif mas[i] == 'T':
		print('YES')
		break
else:
	print('NO')


q = input().split(' ')
n = int(q[0])
k = int(q[1])
s = input()
g = s[s.find('G') % k::k]
if g.find('T') > -1:
	w = [g.find('G'), g.find('T')]
	w.sort()
	q = g[w[0] + 1:w[1]]
	if q.find('#') == -1:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input().strip('.#')
print('NO' if (len(s) - 1) % k or '#' in s[0:len(s):k] else 'YES')


(x, y) = map(int, input().split())
S = input()
g = S.index('G')
t = S.index('T')
if g < t:
	(g, t) = (t, g)
v = True
if (g - t) % y != 0:
	v = False
for i in range(t, g + 1, y):
	if S[i] == '#':
		v = False
		break
if v:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = input()
if c.index('G') > c.index('T'):
	c = c[::-1]
c = c[c.index('G'):]
c = c[:c.index('T') + 1]
j = 0
while j < len(c) - 1:
	if j + b < len(c):
		if c[j + b] == '#':
			exit(print('NO'))
		j += b
	else:
		exit(print('NO'))
print('YES')


(n, k) = list(map(int, input().split()))
polosa = input()
kus = polosa.index('G')
eda = polosa.index('T')
pt = polosa[min(kus, eda):max(kus, eda) + 1]
flag = 'YES'
c = 0
if abs(kus - eda) - k < 0:
	flag = 'NO'
if (len(pt) - 1) % k != 0:
	flag = 'NO'
while c < len(pt) - k:
	if pt[c + k] == '#':
		flag = 'NO'
		break
	else:
		c = c + k
print(flag)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, m) = LI()
	l = S()
	aa = l.index('G')
	bb = l.index('T')
	if aa > bb:
		l = l[::-1]
	st = l.index('G')
	while True:
		if n <= st:
			return 'NO'
		if l[st] == 'T':
			return 'YES'
		if l[st] == '#':
			return 'NO'
		st += m
print(main())


def jumps(n, k, s):
	g = s.index('G')
	t = s.index('T')
	if t < g:
		k = -k
	while g >= 0 and g < n:
		if s[g] == '#':
			return False
		elif s[g] == 'T':
			return True
		g += k
	return False
(n, k) = map(int, input().split())
s = input()
if jumps(n, k, s):
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
g = s.find('G')
t = s.find('T')
l = g - k
if t <= l:
	while l >= 0 and s[l] != '#':
		if s[l] == 'T':
			print('YES')
			exit()
		l -= k
r = g + k
if t >= r:
	while r < len(s) and s[r] != '#':
		if s[r] == 'T':
			print('YES')
			exit()
		r += k
print('NO')


from sys import stdout
INF = float('inf')
(n, k) = map(int, input().split())
maps = input().strip()
dp = [INF for i in range(n)]
dp[maps.index('G')] = 0
for i in range(n):
	if dp[i] != INF and i + k < n and (maps[i + k] != '#'):
		dp[i + k] = 1
for i in range(n - 1, -1, -1):
	if dp[i] != INF and i - k >= 0 and (maps[i - k] != '#'):
		dp[i - k] = 1
if dp[maps.index('T')] != INF:
	stdout.write('YES')
else:
	stdout.write('NO')


(n, k) = list(map(int, input().split()))
s = input()
des = -1
sta = -1
flag = 0
for (i, ch) in enumerate(s):
	if ch == 'T':
		des = i
	elif ch == 'G':
		sta = i
if des > sta:
	for i in range(sta, des + 1, k):
		if s[i] == '#':
			flag = 1
			print('NO')
			break
		elif s[i] == 'T':
			flag = 2
			print('YES')
			break
else:
	for i in range(sta, des - 1, -k):
		if s[i] == '#':
			flag = 1
			print('NO')
			break
		elif s[i] == 'T':
			flag = 2
			print('YES')
			break
if flag == 0:
	print('NO')


(length, jump) = map(int, input().split())
path = input()
start = path.index('G')
finish = path.index('T')
if start > finish:
	(start, finish) = (finish, start)
if (finish - start) % jump == 0:
	if '#' in path[start:finish + 1:jump]:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
if g > t:
	s = s[::-1]
g = s.index('G')
t = s.index('T')
i = g
while i <= t:
	if s[i] == 'T':
		print('YES')
		exit(0)
	elif s[i] == '#':
		print('NO')
		exit(0)
	i += k
print('NO')


(box_len, hop_len) = [int(x) for x in input().split()]
cells = input()
grasshopper = target = -1
for idx in range(box_len):
	if cells[idx] == 'G':
		grasshopper = idx
	elif cells[idx] == 'T':
		target = idx
if target < grasshopper:
	hop_len *= -1
reached = False
for idx in range(grasshopper, target, hop_len):
	if idx + hop_len < box_len and cells[idx + hop_len] == 'T':
		reached = True
		break
	elif idx + hop_len < box_len and cells[idx + hop_len] == '#':
		break
if reached:
	print('YES')
else:
	print('NO')


(n, k) = [int(x) for x in input().split(' ')]
arr = input()
d = {}

def can_reach(pos, n, k, d):
	if arr[pos] == 'T':
		return d
	for i in [1, -1]:
		a = pos - k * i
		if a in d:
			continue
		if a >= 0 and a < n and (arr[a] != '#'):
			d[a] = 1
			d = can_reach(a, n, k, d)
	return d
d = can_reach(arr.find('G'), n, k, d)
print('YES' if arr.find('T') in d else 'NO')


def grass():
	import sys
	(n, m) = (int(x) for x in input().split())
	l = input()
	g_pos = l.index('G')
	t_pos = l.index('T')
	if t_pos < g_pos:
		(t_pos, g_pos) = (g_pos, t_pos)
	g = g_pos
	while g < len(l):
		if l[g] == '#':
			print('NO')
			return
		elif g == t_pos:
			print('YES')
			return
		g += m
	print('NO')
grass()


(n, k) = map(int, input().split())
s = input()
(g, t) = (-1, -1)
for i in range(n):
	if s[i] == 'G':
		g = i
	elif s[i] == 'T':
		t = i
(g, t) = (min(g, t), max(g, t))
if (t - g) % k != 0:
	print('NO')
else:
	res = True
	while g < t and res:
		res = s[g] != '#'
		g += k
	if res:
		print('YES')
	else:
		print('NO')


(n, k) = map(int, input().split())
s = input()
(x, y) = (0, 0)
for i in range(n):
	if s[i] == 'T':
		x = i
	if s[i] == 'G':
		y = i
if x < y:
	f = 0
	for i in range(y, -1, -k):
		if s[i] == '#':
			f = 0
			break
		if s[i] == 'T':
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
elif x > y:
	f = 0
	for i in range(y, n, k):
		if s[i] == '#':
			f = 0
			break
		if s[i] == 'T':
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')


(_, step) = map(int, input().split(' '))
s = str(input())
start = min(s.index('G'), s.index('T'))
for i in range(start + step, len(s), step):
	if s[i] == 'T' or s[i] == 'G':
		print('YES')
		break
	if s[i] == '#':
		print('NO')
		break
else:
	print('NO')


g_data = input().split()
for (i, s) in enumerate(g_data):
	g_data[i] = int(s)
num = g_data[0]
hop = g_data[1]
box = input()
start = box.index('G')
end = box.index('T')
distance = end - start
if distance % hop != 0:
	print('NO')
else:
	if end < start:
		hop *= -1
	obstacle = False
	for cell in range(start, end + 1, hop):
		if cell >= 0 and cell < num:
			if box[cell] is '#':
				obstacle = True
				break
	print('NO' if obstacle else 'YES')


(n, k) = list(map(int, input().split()))
s = list(input())
t = s.index('G')
t1 = s.index('T')
c = 0
if t < t1:
	for i in range(t, n, k):
		if s[i] == '#':
			break
		if i == t1:
			c = 1
			print('YES')
			break
else:
	(t, t1) = (t1, t)
	for i in range(t, n, k):
		if s[i] == '#':
			break
		if i == t1:
			c = 1
			print('YES')
			break
if c == 0:
	print('NO')


string = input()
numbers = string.split()
p = int(numbers[0])
q = int(numbers[1])
string = input()
a = string.index('G')
b = string.index('T')
if a > b:
	(a, b) = (b, a)
results = 'NO'
if abs(a - b) % q == 0:
	results = 'YES'
	for x in range(a, b):
		if string[x] == '#' and abs(a - x) % q == 0:
			results = 'NO'
			break
print(results)


from sys import exit
(n, k) = map(int, input().split())
str = input()
for i in range(len(str)):
	if str[i] == 'G':
		s = i
	if str[i] == 'T':
		t = i
if s > t:
	(s, t) = (t, s)
if (t - s) % k != 0:
	print('NO')
	exit(0)
for i in range(s, t, k):
	if str[i] == '#':
		print('NO')
		exit(0)
print('YES')


nums = input()
nums = nums.strip('\n')
nums = nums.split()
length = int(nums[0])
jump = int(nums[1])
track = input()
track = track.strip('\n')
track = list(track)
grasshopP = track.index('G')
insectP = track.index('T')

def doIt(grasshopPos, insectPos):
	if grasshopPos <= insectPos:
		while grasshopPos <= insectPos and grasshopPos < length:
			if track[grasshopPos] == '#':
				print('NO')
				return
			if grasshopPos == insectPos:
				print('YES')
				return
			grasshopPos += jump
		print('NO')
	else:
		while grasshopPos >= insectPos and grasshopPos >= 0:
			if track[grasshopPos] == '#':
				print('NO')
				return
			if grasshopPos == insectPos:
				print('YES')
				return
			grasshopPos -= jump
		print('NO')
doIt(grasshopP, insectP)


def grass(s, k):
	l = s.index('G')
	r = s.index('G')
	while l >= 0:
		if s[l] == '#':
			break
		if s[l] == 'T':
			return 'YES'
		l -= k
	while r < len(s):
		if s[r] == '#':
			break
		if s[r] == 'T':
			return 'YES'
		r += k
	return 'NO'
(n, k) = list(map(int, input().split()))
s = input()
print(grass(s, k))


(n, k) = [int(s) for s in input().split(' ')]
s = input()
if s.find('T') < s.find('G'):
	s = s[::-1]
s = s[s.find('G')::k]
if s.find('T') == -1 or (s.find('#') != -1 and s.find('#') < s.find('T')):
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
ligne = input()
for i in range(n):
	car = ligne[i]
	if car == 'G':
		depart = i
	elif car == 'T':
		arrive = i
i = depart
while n > i and (ligne[i] == '.' or ligne[i] == 'G'):
	i += k
j = depart
while j > 0 and (ligne[j] == '.' or ligne[j] == 'G'):
	j -= k
if j == arrive or i == arrive:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
x = list(input())
t = 'NO'
start = x.index('G')
end = x.index('T')
if start > end:
	x = x[::-1]
	start = x.index('G')
	end = x.index('T')
x = x[start:end + 1]
for i in range(k, len(x), k):
	if x[i] == 'T':
		t = 'YES'
		break
	elif x[i] == '#':
		t = 'NO'
		break
print(t)


(n, k) = map(int, input().split())
s = input()
c = 1
(m, l) = (s.find('G'), s.find('T'))
if m < l:
	for i in range(m, l + 1, k):
		if s[i] == 'T':
			c = 0
			break
		elif s[i] == '#':
			c = 1
			break
elif m > l:
	for i in range(m, l - 1, -k):
		if s[i] == 'T':
			c = 0
			break
		elif s[i] == '#':
			c = 1
			break
if c == 0:
	print('YES')
else:
	print('NO')


import math
from fractions import Fraction as frac
MOD = 1000000000.0 + 7

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def solve(case_no):
	(n, k) = map(int, input().split())
	s = str(input())
	sp = -1
	ep = -1
	for i in range(n):
		if s[i] == 'G':
			sp = i
		elif s[i] == 'T':
			ep = i
	if sp > ep:
		(sp, ep) = (ep, sp)
	if (ep - sp) % k != 0:
		print('NO')
		exit()
	for i in range(sp + k, ep, k):
		if s[i] == '#':
			print('NO')
			exit()
	print('YES')
t = 1
for i in range(1, t + 1):
	solve(i)


(n, k) = map(int, input().split())
s = list(input())
if s.index('G') > s.index('T'):
	s.reverse()
j = s.index('G')
t = s.index('T')
flag = 0
while t - j > 0:
	if j + k < n and (s[j + k] == '.' or s[j + k] == 'T') and (t - j - k >= 0):
		j = j + k
		flag = 1
	else:
		flag = 0
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = input()
pos = -1
for i in range(n):
	if a[i] == 'G':
		pos = i
		break
for i in range(pos, len(a), k):
	if a[i] == 'T':
		print('YES')
		exit()
	if a[i] == '#':
		break
for i in range(pos, -1, -k):
	if a[i] == 'T':
		print('YES')
		exit()
	if a[i] == '#':
		break
print('NO')


def solve(n, k, seq):
	g = seq.index('G')
	for i in range(g, len(seq), k):
		if seq[i] == '#':
			break
		elif seq[i] == 'T':
			return True
	for i in range(g, -1, -k):
		if seq[i] == '#':
			break
		elif seq[i] == 'T':
			return True
	return False

def main():
	(n, k) = map(int, input().split())
	seq = input()
	print('YES' if solve(n, k, seq) else 'NO')
main()


from sys import stdin, stdout

def trace(f):

	def traced(*args, **kw):
		print('calling {} with args {}, {}'.format(f.__name__, args, kw))
		return f(*args, **kw)
	return traced

@trace
def f(x):
	print(x)

def read():
	return stdin.readline()[:-1]

def readarr(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readintarr(sep=None, maxsplit=-1):
	return [int(a) for a in readarr(sep, maxsplit)]

def write(*args, **kwargs):
	sep = kwargs.get('sep', ' ')
	end = kwargs.get('end', '\n')
	stdout.write(sep.join((str(a) for a in args)) + end)

def writearr(arr, sep=' ', end='\n'):
	stdout.write(sep.join((str(a) for a in arr)) + end)
(n, k) = readintarr()
L = read()
(g, t, os) = (-1, -1, set())
for (i, c) in enumerate(L):
	if c == 'G':
		g = i
	elif c == 'T':
		t = i
	elif c == '#':
		os.add(i)
lim = t + 1
if t < g:
	k = -k
	lim = t - 1
x = os
for i in range(g, lim, k):
	if i in os:
		print('NO')
		break
	elif i == t:
		print('YES')
		break
else:
	print('NO')


def main():
	(n, k) = map(int, input().split(' '))
	s = list(input())
	G = s.index('G')
	T = s.index('T')
	v = set()
	for j in range(G, n, k):
		if s[j] == '#':
			break
		v.add(j)
	for j in range(G, -1, -k):
		if s[j] == '#':
			break
		v.add(j)
	return 'YES' if T in v else 'NO'
print(main())


def f():
	(n, k) = map(int, input().split())
	s = input()
	(g, t) = (s.index('G'), s.index('T'))
	if g > t:
		(g, t) = (t, g)
	for i in range(g, t + 1, k):
		if s[i] == '#':
			return False
		if i == t:
			return True
	return False
if f():
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
p = list(str(input()))
if p.index('G') > p.index('T'):
	p = p[::-1]
for i in range(p.index('G'), n, k):
	if p[i] == '#':
		print('NO')
		break
	if p[i] == 'T':
		print('YES')
		break
else:
	print('NO')


X = list(map(int, input().split()))
S = input()
Place = (S[S.index('G') + X[1]::X[1]] if S.index('G') < S.index('T') else S[S.index('G') - X[1]::-X[1]]) + '#'
print('YES' if 'T' in Place and Place.index('T') < Place.index('#') else 'NO')


def main():
	[n, k] = [int(_) for _ in input().split()]
	line = input()
	index_g = line.index('G')
	index_t = line.index('T')
	distance = abs(index_g - index_t)
	if distance % k != 0:
		print('NO')
	else:
		has_obstacles = False
		for i in range(min(index_t, index_g), max(index_t, index_g) + 1, k):
			if line[i] == '#':
				has_obstacles = True
				break
		print('NO' if has_obstacles else 'YES')
main()


(n, k) = map(int, input().split())
s = input()
(G, T) = (-1, -1)
for i in range(n):
	if s[i] == 'G':
		G = i
	elif s[i] == 'T':
		T = i
if G < T:
	while G < T and s[G] != '#':
		G += k
		if G < n and s[G] == 'T':
			print('YES')
			exit()
	print('NO')
else:
	while G > T and s[G] != '#':
		G -= k
		if G >= 0 and s[G] == 'T':
			print('YES')
			exit()
	print('NO')


import math
(n, k) = map(int, input().split())
cells = input()

def findPath(n, k, cells):
	line = []
	grasshoper_pos = None
	target_pos = None
	counter = 0
	for char in cells:
		line.append(char)
		if char == 'G':
			grasshoper_pos = counter
		elif char == 'T':
			target_pos = counter
		counter += 1
	if abs(target_pos - grasshoper_pos) % k == 0:
		if target_pos > grasshoper_pos:
			for x in range(grasshoper_pos, target_pos, k):
				if line[x] == '#':
					return 'NO'
		else:
			for x in reversed(range(grasshoper_pos, target_pos, -k)):
				if line[x] == '#':
					return 'NO'
		return 'YES'
	else:
		return 'NO'
print(findPath(n, k, cells))


import sys
info = sys.stdin.readline().split()
k = int(info[1])
line = list(sys.stdin.readline())
g = -1
t = -1
obstacles = [False] * len(line)
for (i, c) in enumerate(line):
	if c == 'T':
		t = i
	elif c == 'G':
		g = i
	elif c == '#':
		obstacles[i] = True
if t < g:
	k = 0 - k
while g != t:
	if g < 0 or g > len(obstacles) - 1:
		break
	if obstacles[g]:
		break
	g += k
if g == t:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
gi = s.index('G')
ti = s.index('T')
if gi > ti:
	s = s[::-1]
	gi = s.index('G')
	ti = s.index('T')
s = list(s[gi:ti + 1])
mistake = False
if len(s) <= k:
	mistake = True
else:
	for i in range(0, len(s), k):
		if s[i] == '#':
			mistake = True
		last = s[i]
	if last != 'T':
		mistake = True
if not mistake:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
id1 = s.find('G')
id2 = s.find('T')
if abs(id1 - id2) % k:
	print('NO')
	exit()
coef = 1
if id2 < id1:
	coef = -1
while id1 != id2 and s[id1] in ('G', '.', 'T'):
	id1 += coef * k
if id1 == id2:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
if t > g:
	while t >= g:
		if s[g] == '#':
			print('NO')
			exit()
		elif t == g:
			print('YES')
			exit()
		g += k
else:
	while t <= g:
		if s[g] == '#':
			print('NO')
			exit()
		elif t == g:
			print('YES')
			exit()
		g -= k
print('NO')


(a, b) = map(int, input().split())
s = input('')
c = s.index('T')
d = s.index('G')
if (max(c, d) - min(c, d)) % b == 0:
	for x in range(min(c, d), max(c, d), b):
		if s[x] == '#':
			print('NO')
			exit()
else:
	print('NO')
	exit()
print('YES')


import math

def solve(n, k, s):
	(i, j) = (s.index('G'), s.index('T'))
	if (i - j) % k != 0:
		return False
	for k in range(i, j, k if i < j else -k):
		if k >= n or k < 0 or s[k] == '#':
			return False
	return True
(n, k) = [int(x) for x in input().split()]
s = input()
print('YES' if solve(n, k, s) else 'NO')


line1 = [int(x) for x in input().split(' ')]
n = line1[0]
k = line1[1]
line2 = input()
for i in range(len(line2)):
	if line2[i] == 'G':
		start_point = i
	if line2[i] == 'T':
		dest = i
if abs(start_point - dest) % k != 0:
	print('NO')
else:
	flag = True
	if start_point - dest > 0:
		direction = False
	else:
		direction = True
	steps = int(abs(start_point - dest) / k)
	for i in range(steps):
		if direction:
			if line2[start_point + i * k] == '#':
				print('NO')
				flag = False
				break
		elif line2[start_point - i * k] == '#':
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


import sys

def checkLeft(i, k, str):
	while i >= 0:
		if str[i] == 'T':
			return True
		elif str[i] == '#':
			return False
		i -= k
	return False

def checkRight(j, k, str):
	while j < len(str):
		if str[j] == 'T':
			return True
		elif str[j] == '#':
			return False
		j += k
	return False
line = sys.stdin.readline()
str = sys.stdin.readline()
nums = line.split(' ')
n = int(nums[0])
k = int(nums[1])
i = str.find('G')
j = str.find('G')
if checkLeft(i, k, str) or checkRight(i, k, str):
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
c = input()
for i in range(n):
	if c[i] == 'G':
		g = i
	if c[i] == 'T':
		t = i
stat = True
if (g - t) % k != 0:
	print('NO')
else:
	if g > t:
		while g > t:
			if c[t + k] == '#':
				stat = False
			t = t + k
	else:
		while g < t:
			if c[g + k] == '#':
				stat = False
			g = g + k
	if stat:
		print('YES')
	else:
		print('NO')


inp = input().split()
(n, k) = (inp[0], int(inp[1]))
line = input()
grasshopper = line.find('G')
insect = line.find('T')
passed = False
if grasshopper < insect:
	while True:
		if grasshopper >= len(line):
			passed = False
			break
		if line[grasshopper] == '#':
			passed = False
			break
		if grasshopper > insect:
			passed = False
			break
		if grasshopper == insect:
			passed = True
			break
		else:
			grasshopper = grasshopper + k
elif grasshopper > insect:
	while True:
		if grasshopper < 0:
			passed = False
			break
		if line[grasshopper] == '#':
			passed = False
			break
		if grasshopper < insect:
			passed = False
			break
		if grasshopper == insect:
			passed = True
			break
		else:
			grasshopper = grasshopper - k
		pass
print('YES' if passed else 'NO')


(a, b) = list(map(int, input().split()))
c = input()
(i, j) = (c.index('G'), c.index('T'))
c = c[min(i, j):max(i, j) + 1]
d = [c[i] for i in range(0, len(c), b)]
print('YES' if '#' not in d and 'G' in d and ('T' in d) else 'NO')


(n, k) = list(map(int, input().split()))
a = input()
g = 0
t = 0
for j in range(n):
	if a[j] == 'G':
		g = j
	if a[j] == 'T':
		t = j
if g < t:
	(g, t) = (t, g)
if (g - t) % k == 0:
	per = 0
	for j in range(t, g + 1, k):
		if a[j] == '#':
			per = 1
			break
	if per == 1:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


(n, k) = [int(x) for x in input().split()]
s = input()
l = s.find('G')
r = s.find('T')
if r < l:
	k = -k
f = False
while 1:
	l += k
	if l < 0 or l >= n:
		break
	if l == r:
		print('YES')
		f = True
		break
	elif s[l] == '#':
		print('NO')
		f = True
		break
if not f:
	print('NO')


__author__ = 'Dilshod'
(n, k) = map(int, input().split())
s = input()
g = s.find('G')
t = s.find('T')
a = abs(g - t)
if a % k != 0:
	print('NO')
	exit()
for i in range(min(g, t), max(g, t), k):
	if s[i] == '#':
		print('NO')
		exit()
print('YES')


(n, k) = [int(x) for x in input().split()]
s = input()
if s.index('G') > s.index('T'):
	s = s[::-1]
x = s.index('G')
for i in range(x, n):
	x += k
	if x > n - 1 or s[x] == '#':
		print('NO')
		break
	elif s[x] == 'T':
		print('YES')
		break


from collections import deque
nums = input().split()
n = int(nums[0])
k = int(nums[1])
state = list(input())
b = False
d = deque([])
d.append(state.index('G'))
state[state.index('G')] = 'V'
while d:
	c = d.popleft()
	low = c - k
	high = c + k
	if low >= 0:
		if state[low] == 'T':
			b = True
		elif state[low] == '.':
			state[low] = 'V'
			d.append(low)
	if high < n:
		if state[high] == 'T':
			b = True
		elif state[high] == '.':
			state[high] = 'V'
			d.append(high)
if b:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
l = list(input())
(gi, ti) = (l.index('G'), l.index('T'))
if gi > ti:
	k *= -1
if (gi - ti) % k:
	print('NO')
else:
	while gi != ti:
		if l[gi] == '#':
			print('NO')
			break
		gi += k
	else:
		print('YES')


(n, k) = map(int, input().split())
s = input()
b = set()
index = min(s.index('G'), s.index('T'))
while index <= max(s.index('G'), s.index('T')):
	b.add(s[index])
	index += k
if '#' in b or abs(s.index('G') - s.index('T')) % k != 0:
	print('NO')
else:
	print('YES')


a = [int(i) for i in input().split()]
n = a[0]
k = int(a[1])
s = input()
i1 = 0
i2 = 0
dc = 0
hc = 0
for i in range(len(s)):
	if s[i] == 'G':
		i1 = i
	elif s[i] == 'T':
		i2 = i
	elif s[i] == '.':
		dc += 1
	elif s[i] == '#':
		hc += 1
flag = 0
done = 0
if len(s) - 2 == dc and k == 1:
	print('YES')
	raise SystemExit(0)
elif i2 - i1 == k:
	print('YES')
	raise SystemExit(0)
if i1 < i2:
	for i in range(i1, i2 + 1, k):
		if s[i] == '#':
			print('NO')
			raise SystemExit(0)
			break
		elif s[i] == 'T':
			flag = 0
			print('YES')
			raise SystemExit(0)
		elif s[i] == '.':
			continue
		else:
			flag = 1
elif i1 > i2:
	for i in range(i2, i1 + 1, k):
		if s[i] == '#':
			flag = 1
			print('NO')
			raise SystemExit(0)
		elif s[i] == 'G':
			flag = 0
			print('YES')
			raise SystemExit(0)
		elif s[i] == '.':
			continue
		else:
			flag = 1
if flag == 1:
	print('NO')


(n, k) = map(int, input().split())
s = list(input())
tindex = s.index('T')
gindex = s.index('G')
if tindex > gindex:
	for char in s[gindex:tindex + 1:k]:
		if char == 'T':
			print('YES')
			exit()
		if char == '#':
			print('NO')
			exit()
	print('NO')
else:
	for char in s[tindex:gindex + 1:k]:
		if char == 'G':
			print('YES')
			exit()
		if char == '#':
			print('NO')
			exit()
	print('NO')


(n, k) = [int(x) for x in input().split(' ')]
string = input()
g_index = string.index('G')
t_index = string.index('T')
if g_index > t_index:
	elems = list(string)
	(elems[g_index], elems[t_index]) = (elems[t_index], elems[g_index])
	(g_index, t_index) = (t_index, g_index)
	string = ''.join(elems)
if abs(g_index - t_index) % k != 0:
	print('NO')
else:
	i = g_index
	while i < n:
		if string[i] == 'T':
			print('YES')
			break
		if string[i] == '#':
			print('NO')
			break
		i += k


(a, b) = input().split()
a = int(a)
b = int(b)
disa = disb = -1
str = input()
Flag = True
for i in range(a):
	if str[i] == 'G':
		disa = i
	if str[i] == 'T':
		disb = i
if disa > disb:
	(disa, disb) = (disb, disa)
if (disb - disa) % b:
	Flag = False
else:
	for i in range(disa, disb + 1, b):
		if str[i] == '#':
			Flag = False
if Flag:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
l = list(input())
for i in range(n):
	if l[i] == 'G' or l[i] == 'T':
		for j in range(i, n, k):
			if j == i:
				continue
			if l[j] == '#':
				print('NO')
				break
			elif l[j] == 'G' or l[j] == 'T':
				print('YES')
				break
		else:
			print('NO')
		break


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, k) = LI()
	s = S()
	g = s.index('G')
	t = s.index('T')
	if g > t:
		(g, t) = (t, g)
	if (t - g) % k != 0:
		return 'NO'
	while g < t:
		g += k
		if s[g] == '#':
			return 'NO'
	return 'YES'
print(main())


(n, k) = map(int, input().split())
s = input()
(x, y) = (s.index('G'), s.index('T'))
if (x - y) % k != 0:
	print('NO')
else:
	flag = 0
	if x > y:
		k = -1 * k
	for i in range(x, y, k):
		if s[i] == '#':
			flag = 1
	if flag:
		print('NO')
	else:
		print('YES')


(n, k) = map(int, input().split())
string = input()
g = string.index('G')
t = string.index('T')
if abs(t - g) % k == 0:
	for i in range(min(g, t), max(g, t), k):
		if string[i] == '#':
			print('NO')
			exit()
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
line = input()
start = next((i for (i, v) in enumerate(line) if v == 'G'))
end = next((i for (i, v) in enumerate(line) if v == 'T'))
if (start - end) % k != 0:
	print('NO')
	exit()
(start, end) = (min(start, end), max(start, end))
if all((line[i] != '#' for i in range(start, end, k))):
	print('YES')
else:
	print('NO')


data = input()
n = data.split(' ')[0]
s = data.split(' ')[1]
p = True
pos = 0
p_insecto = 0
trampas = []
celda = input()
for i in range(0, len(celda)):
	if celda[i] == 'G':
		pos = i
	if celda[i] == 'T':
		p_insecto = i
	if celda[i] == '#':
		trampas.append(i)
if pos > p_insecto:
	c = pos
	pos = p_insecto
	p_insecto = c
d = p_insecto - pos
if d % int(s) != 0 and p:
	print('NO')
	p = False
aux = pos + int(s)
while aux <= p_insecto - int(s):
	if celda[aux] == '#' and p:
		print('NO')
		p = False
	aux = aux + int(s)
if p:
	print('YES')


(strLength, jumpLength) = map(int, input().split())
line = str(input())
grasshopper = line.find('G')
target = line.find('T')
if abs(grasshopper - target) % jumpLength != 0:
	print('NO')
else:
	checker = None
	i = 0
	j = 1
	if grasshopper < target:
		while target - grasshopper > i:
			if line[grasshopper + jumpLength * j] == '#':
				print('NO')
				checker = True
				break
			i = i + jumpLength
			j = j + 1
		if not checker:
			print('YES')
	elif target < grasshopper:
		while grasshopper - target > i:
			if line[grasshopper - jumpLength * j] == '#':
				print('NO')
				checker = True
				break
			i = i + jumpLength
			j = j + 1
		if not checker:
			print('YES')
	else:
		print('YES')


(n, k) = map(int, input().split())
line = input()

def solve_right(n, k, line):
	g = line.find('G')
	i = g
	while i < n - k:
		i += k
		if line[i] == 'T':
			return True
		elif line[i] == '#':
			return False
	return False

def solve_left(n, k, line):
	g = line.find('G')
	i = g
	while i >= k:
		i -= k
		if line[i] == 'T':
			return True
		elif line[i] == '#':
			return False
	return False
if solve_left(n, k, line) or solve_right(n, k, line):
	print('YES')
else:
	print('NO')


l1 = input().split()
l = int(l1[0])
jump = int(l1[1])
string = input()
g = string.find('G')
t = string.find('T')
if g != 0 and g + 1 < len(string):
	if jump != 1 and (string[g + 1] == 'T' or string[g - 1] == 'T'):
		print('NO')
		exit()
if g == 0 and g + 1 < len(string):
	if jump != 1 and string[g + 1] == 'T':
		print('NO')
		exit()
if g == len(string) - 1:
	if jump != 1 and string[g - 1] == 'T':
		print('NO')
		exit()
if t > g:
	while g < len(string) - jump:
		g += jump
		if string[g] == '#':
			print('NO')
			exit()
		elif string[g] == '.':
			continue
		else:
			print('YES')
			exit()
	print('NO')
	exit()
else:
	while g > 0:
		g -= jump
		if string[g] == '#':
			print('NO')
			exit()
		elif string[g] == '.':
			continue
		else:
			print('YES')
			exit()
	print('NO')


(n, k) = map(int, input().split())
s = input()
(G, T) = (s.find('G'), s.find('T'))
if G > T:
	for i in range(T, G + 1, k):
		if s[i] != '#':
			if s[i] == 'G':
				exit(print('YES'))
		else:
			break
if G < T:
	for i in range(G, T + 1, k):
		if s[i] != '#':
			if s[i] == 'T':
				exit(print('YES'))
		else:
			break
print('YES' if G == T else 'NO')


import math
import sys
import re

def g(n, s, k):
	if abs(s.index('G') - s.index('T')) == k:
		return 'YES'
	elif abs(s.index('G') - s.index('T')) % k != 0:
		return 'NO'
	elif s.index('G') < s.index('T'):
		m = s.index('G') + k
		while m < n:
			if s[m] == '#':
				return 'NO'
			elif s[m] == 'T':
				return 'YES'
			else:
				m = m + k
	else:
		m = s.index('G') - k
		while m >= 0:
			if s[m] == '#':
				return 'NO'
			elif s[m] == 'T':
				return 'YES'
			else:
				m = m - k
(n, k) = map(int, input().rstrip().split())
s = input()
print(g(n, s, k))


import sys
(n, k) = map(int, input().split())
s = input()
a = s.index('G')
b = s.index('T')
while a < b:
	b = b - k
	pos = b
	if pos >= 0 and (s[pos] == '.' or s[pos] == 'T'):
		pass
	else:
		break
while a > b:
	b = b + k
	pos = b
	if pos < n and (s[pos] == '.' or s[pos] == 'T'):
		pass
	else:
		break
if a != b:
	print('NO')
else:
	print('YES')


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))

def case():
	(n, k) = li()
	s = input().strip()
	p = s.index('G')
	q = s.index('T')
	(p, q) = (min(p, q), max(p, q))
	if (q - p) % k != 0:
		print('NO')
		exit()
	i = p
	while i < q:
		if s[i] == '#':
			print('NO')
			exit()
		i += k
	print('YES')
for _ in range(1):
	case()


ins = list(map(int, input().split()))
n = ins[0]
k = ins[1]
ins = input()
for i in range(0, len(ins)):
	if ins[i] == 'G':
		g = i
	if ins[i] == 'T':
		t = i
tr = True
if (t - g) % k == 0:
	p = t - g
	if p < 0:
		while ins[g] != 'T':
			if ins[g] == '#':
				tr = False
			g -= k
	else:
		while ins[g] != 'T':
			if ins[g] == '#':
				tr = False
			g += k
else:
	tr = False
if tr:
	print('YES')
else:
	print('NO')


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
from fractions import Fraction

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)
(n, k) = mi()
s = list(si())
x = s.index('G')
y = s.index('T')
if x > y:
	s = s[::-1]
x = s.index('G')
y = s.index('T')
i = x
while i < n:
	if i + k >= n:
		break
	if s[i + k] == '#':
		print('NO')
		exit()
	elif s[i + k] == 'T':
		print('YES')
		exit()
	if i + k < n:
		i += k
	else:
		break
print('NO')


(n, k) = map(int, input().split())
ss = input()
s = []
g = 0
t = 0
u = 0
for i in ss:
	s.append(i)
	if i == 'G':
		g = u
	if i == 'T':
		t = u
	u = u + 1
if g < t:
	i = g
	r = 0
	while i < n:
		if s[i] == '#':
			r = 0
			break
		if s[i] == 'T':
			r = 1
			break
		i = i + k
	if r == 0:
		print('NO')
	else:
		print('YES')
elif g > t:
	i = g
	r = 0
	while i >= 0:
		if s[i] == '#':
			r = 0
			break
		if s[i] == 'T':
			r = 1
			break
		i = i - k
	if r == 0:
		print('NO')
	else:
		print('YES')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
check = 0
g = s.index('G')
des = s.index('T')
if (des - g) % k != 0:
	print('NO')
else:
	if g < des:
		for i in range(g, des, k):
			if s[i] == '#':
				print('NO')
				check = 1
				break
	else:
		for i in range(des, g, k):
			if s[i] == '#':
				print('NO')
				check = 1
				break
	if check == 0:
		print('YES')


def solution(s, step):
	(idxG, idxT) = (0, 0)
	for i in range(len(s)):
		if s[i] == 'G':
			idxG = i
		if s[i] == 'T':
			idxT = i
	if idxG < idxT:
		while idxG < len(s):
			if s[idxG] == 'T':
				return 'YES'
			elif s[idxG] == '#':
				return 'NO'
			idxG += step
		return 'NO'
	else:
		while idxG >= 0:
			if s[idxG] == 'T':
				return 'YES'
			elif s[idxG] == '#':
				return 'NO'
			idxG -= step
		return 'NO'
(n, step) = input().strip().split()
s = input()
print(solution(s, int(step)))


(n, k) = map(int, input().split())
s = input()
if s.index('T') < s.index('G'):
	x = 0
	i = s.index('G')
	while i >= 0:
		i -= k
		if i >= 0 and s[i] == '#':
			break
		elif i >= 0 and s[i] == 'T':
			x = 1
			break
	if x:
		print('YES')
	else:
		print('NO')
else:
	x = 0
	i = s.index('G')
	while i < n:
		i += k
		if i < n and s[i] == '#':
			break
		elif i < n and s[i] == 'T':
			x = 1
			break
	if x:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
l = input()
(h, k) = (l.index('G'), l.index('T'))
c = 0
if h > k:
	for i in range(max(0, h - m), k - 1, -m):
		if l[i] == '#':
			c = 'NO'
			break
		elif l[i] == 'T':
			c = 'YES'
			break
else:
	for i in range(h + m, k + 1, m):
		if l[i] == '#':
			c = 'NO'
			break
		elif l[i] == 'T':
			c = 'YES'
			break
print('NO') if c == 0 else print(c)


(n, k) = map(int, input().split())
x = input()
a = x.index('G')
b = x.index('T')
(a, b) = (min(a, b), max(a, b))
if abs(a - b) % k == 0:
	out = True
	for i in range(abs(a - b) // k - 1):
		if x[a + k] != '.' and x[a + k] != 'T':
			out = False
			break
		else:
			a += k
	if out:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, k) = str(input()).split()
(n, k) = (int(n), int(k))
line = str(input())
(pos_l, pos_r) = (-1, -1)
for i in range(n):
	if line[i] in ('G', 'T'):
		if pos_l >= 0:
			pos_r = i
		else:
			pos_l = i
if (pos_r - pos_l) % k > 0:
	print('NO')
else:
	flag = True
	for i in range(pos_l, pos_r, k):
		if line[i] == '#':
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


(n, k) = map(int, input().split())
s = list(input())
g = 0
t = 0
for (i, m) in enumerate(s):
	if m == 'T' or m == 'G':
		for j in range(i + k, len(s), k):
			if s[j] == '#':
				print('NO')
				exit(0)
			if s[j] == 'G' or s[j] == 'T':
				print('YES')
				exit(0)
print('NO')


(n, k) = map(int, input().split())
a = input()
b = a.index('G')
c = a.index('T')
d = ''
for i in range(n):
	if i % k == b % k:
		d += a[i]
if 'T' not in d:
	print('NO')
	exit()
if b < c:
	d = d[d.index('G'):d.index('T')]
else:
	d = d[d.index('T'):d.index('G')]
if '#' not in d:
	print('YES')
	exit()
print('NO')


(n, k) = map(int, input().split())
s = input()
g = s.find('G')
t = s.find('T')
ans = 'NO'
if g < t:
	for i in range(g + k, t + 1, k):
		if s[i] == '.':
			continue
		if s[i] == 'T':
			ans = 'YES'
		break
else:
	for i in range(g - k, t - 1, -k):
		if s[i] == '.':
			continue
		if s[i] == 'T':
			ans = 'YES'
		break
print(ans)


(n, k) = list(map(int, input().split()))
st = list(input())
g = st.index('G')
t = st.index('T')
if abs(g - t) % k != 0:
	print('NO')
else:
	start = min(g, t)
	end = max(g, t)
	while start != end:
		start += k
		if st[start] == '#':
			print('NO')
			return
	print('YES')


(n, k) = map(int, input().split())
s = input()
a = s.index('G')
b = s.index('T')
i = a
ans = 'NO'
if b < a:
	while i - k >= 0 and s[i - k] != '#':
		i -= k
		if s[i] == 'T':
			ans = 'YES'
else:
	while i + k < n and s[i + k] != '#':
		i += k
		if s[i] == 'T':
			ans = 'YES'
print(ans)


(n, k) = [int(i) for i in input().split()]
s = input()
a = s.find('G')
b = s.find('T')
ans = 'NO'
if a < b:
	for i in range(a, n, k):
		if s[i] == '#':
			break
		if s[i] == 'T':
			ans = 'YES'
			break
else:
	for i in range(b, n, k):
		if s[i] == '#':
			break
		if s[i] == 'G':
			ans = 'YES'
			break
print(ans)


(n, k) = map(int, input().split())
s = input()
a = s.index('G')
b = s.index('T')
d = [0] * 1000
d[a] = 1
for j in range(200):
	for i in range(n):
		if i - k >= 0 and d[i - k] == 1 and (s[i] != '#'):
			d[i] = 1
		if d[i + k] == 1 and s[i] != '#':
			d[i] = 1
if d[b]:
	print('YES')
else:
	print('NO')


(a, b) = [int(i) for i in input().split()]
s = str(input())
q = s.index('G')
w = s.index('T')
d = 0
e = 0
if q > w:
	s = s[::-1]
	q = s.index('G')
	w = s.index('T')
for i in range(q, w + 1, b):
	if s[i] == '#':
		e = e + 1
	elif s[i] == 'T':
		d = 1
if d == 1 and e == 0:
	print('YES')
elif e > 0:
	print('NO')
elif abs(q - w) < b:
	print('NO')
else:
	print('NO')


(ls, j) = list(map(int, input().split()))
inp = input()
g = inp.index('G')
t = inp.index('T')
for i in range(min(g, t), max(g, t) + 1, j):
	if inp[i] == '#':
		print('NO')
		break
	if inp[i] == inp[max(g, t)]:
		print('YES')
		break
else:
	print('NO')


(n, k) = map(int, input().split())
a = list(input())
i = a.index('G')
j = a.index('T')
if i > j:
	(i, j) = (j, i)
while True:
	if i == j:
		print('YES')
		break
	elif i >= j or a[i] == '#':
		print('NO')
		break
	else:
		i += k


(n, k) = map(int, input().split())
stroka = input()
kuz = stroka.find('G')
nas = stroka.find('T')
if kuz < nas:
	i = kuz + k
	while i < len(stroka) and stroka[i] != '#':
		if stroka[i] == 'T':
			print('YES')
			break
		i += k
	else:
		print('NO')
else:
	i = kuz - k
	while i >= 0 and stroka[i] != '#':
		if stroka[i] == 'T':
			print('YES')
			break
		i -= k
	else:
		print('NO')


def f(n, k, s):
	g_index = -1
	i_index = -1
	for (i, c) in enumerate(s):
		if c == 'T':
			i_index = i
		if c == 'G':
			g_index = i
	if abs(g_index - i_index) % k != 0:
		print('NO')
		return
	comp = None
	add = k
	if g_index > i_index:
		comp = lambda x: x >= 0
		add = -k
	else:
		comp = lambda x: x < n
	while comp(g_index):
		if s[g_index] == '#':
			print('NO')
			return
		if s[g_index] == 'T':
			print('YES')
			return
		g_index += add
(n, k) = map(int, input().split())
s = input()
f(n, k, s)


k = int(input().split()[1])
s = input()
(a, b) = (s.find('G'), s.find('T'))
if (a - b) % k != 0:
	print('NO')
else:
	if a > b:
		(a, b) = (b, a)
	print('NO' if '#' in s[a:b:k] else 'YES')


(n, m) = map(int, input().split())
s = str(input())
c = 0
target = s.index('T')
start = s.index('G')
if (target - start) % m == 0:
	if target - start > 0:
		for i in range(start, target + 1, m):
			if s[i] == '#':
				c = 1
				break
	else:
		for i in range(target, start + 1, m):
			if s[i] == '#':
				c = 1
				break
else:
	c = 1
if c == 1:
	print('NO')
else:
	print('YES')


from sys import stdin
(n, k) = map(int, stdin.readline().rstrip().split())
cells = stdin.readline().split()[0]
g_pos = cells.index('G')
t_pos = cells.index('T')
output = ''
if g_pos > t_pos:
	ptr = g_pos - k
	while ptr >= 0:
		if cells[ptr] == '#':
			output = 'NO'
			break
		elif cells[ptr] == 'T':
			output = 'YES'
			break
		else:
			ptr = ptr - k
	if ptr < 0:
		output = 'NO'
else:
	ptr = g_pos + k
	while ptr < n:
		if cells[ptr] == '#':
			output = 'NO'
			break
		elif cells[ptr] == 'T':
			output = 'YES'
			break
		else:
			ptr = ptr + k
	if ptr >= n:
		output = 'NO'
print(output)


(n, k) = map(int, input().split())
l = input()
l = l[min(l.index('G'), l.index('T')):max(l.index('G'), l.index('T')) + 1]

def jumper(l, k):
	if (len(l) - 1) % k is 0:
		for i in range(0, len(l), k):
			if l[i] is '#':
				return 'NO'
		return 'YES'
	else:
		return 'NO'
print(jumper(l, k))


(n, m) = map(int, input().split())
a = list(input())
if abs(a.index('G') - a.index('T')) % m != 0:
	print('No')
else:
	i = a.index('G')
	j = a.index('T')
	if i > j:
		flag = 0
		while i >= j:
			if a[i] == '#':
				print('No')
				flag = 1
				break
			else:
				i = i - m
		if flag == 0:
			print('Yes')
	else:
		flag = 0
		while i <= j:
			if a[i] == '#':
				print('No')
				flag = 1
				break
			else:
				i = i + m
		if flag == 0:
			print('Yes')


(n, k) = map(int, input().split())
s = input()
b = False
j = s.index('G')
for i in range(j + k, n, k):
	if s[i] == 'T':
		print('YES')
		b = True
		break
	if s[i] == '#':
		break
if b == False:
	for i in range(j - k, -1, -k):
		if s[i] == 'T':
			print('YES')
			b = True
			break
		if s[i] == '#':
			break
if b == False:
	print('NO')


(n, k) = [int(i) for i in input().split()]
game = list(input())
for i in range(len(game)):
	if game[i] == 'T':
		st = i
	if game[i] == 'G':
		en = i
out = 'YES'
if (max(st, en) - min(st, en)) % k != 0:
	out = 'NO'
for i in range(min(st, en), max(st, en), k):
	if game[i] == '#':
		out = 'NO'
		break
print(out)


def main():
	input_specs = []
	for spec in input().split(' '):
		input_specs.append(int(spec))
	jump_len = input_specs[1]
	cells = []
	path = input()
	for cell in path:
		cells.append(cell)
	empty = '.'
	obstacle = '#'
	jump = 1
	index = 0
	toTarget = False
	while index < len(cells):
		if not toTarget:
			if cells[index] != empty and cells[index] != obstacle:
				toTarget = True
				jump = jump_len
		elif cells[index] == obstacle:
			print('NO')
			return
		elif cells[index] != empty:
			print('YES')
			return
		index += jump
	print('NO')
main()


c = input()
x = [i for i in c.split()]
t = input()
y = int(x[1])
h = 0
d = 0
u = 0
j = 0
for i in range(len(t)):
	if t[i] == 'T':
		h = 9
		m = i
	if t[i] == 'G':
		d = 9
		r = i
if m > r:
	v = r
	while t[v] != '#' and v + y <= len(t):
		if v + y <= len(t) - 1:
			v = v + y
		if t[v] == 'T':
			print('yes')
			u = 1
			break
		if t[v] == '#':
			print('no')
			j = 1
			break
		if v + y > len(t) - 1:
			break
	if u != 1 and j != 1:
		print('no')
if m < r:
	v = r
	while t[v] != '#' and v - y >= -1:
		if v - y >= 0:
			v = v - y
		if t[v] == 'T':
			print('yes')
			u = 1
			break
		if t[v] == '#':
			print('no')
			j = 1
			break
		if v - y < 0:
			break
	if u != 1 and j != 1:
		print('no')


from sys import stdin
nums = stdin.readline().strip().split(' ')
jump = int(nums[1])
positions = stdin.readline().strip()
start = positions.index('G')
end = positions.index('T')
positions = list(positions)
if (start - end) % jump != 0:
	print('NO')
else:
	times = (start - end) // jump
	if times < 0:
		times *= -1
	found = False
	for i in range(0, times):
		if start < end:
			loc = start + (i + 1) * jump
		else:
			loc = start - (i + 1) * jump
		if positions[loc] == 'T':
			found = True
			break
		elif positions[loc] == '#':
			found = False
			break
	if found == True:
		print('YES')
	else:
		print('NO')


q = input().split()
w = input()
e1 = int(q[0])
e2 = int(q[1])
y = True
for i in range(e1):
	if w[i] == 'G':
		r = i
	elif w[i] == 'T':
		t = i
if r < t:
	for i in range(r, t, e2):
		if w[i] == '#':
			y = False
if r > t:
	for i in range(r, t, -e2):
		if w[i] == '#':
			y = False
if y == True and (r - t) % e2 == 0:
	print('YES')
else:
	print('NO')


import sys
z = list(map(int, input().split()))
x = list(map(str, input()))
c = [i for i in range(z[0]) if x[i] == 'T' or x[i] == 'G']
for i in range(min(c) + z[1], z[0], z[1]):
	if x[i] == 'G' or x[i] == 'T':
		print('YES')
		sys.exit(0)
	if x[i] == '#':
		break
print('NO')


__author__ = 'Alexander'
import sys
(n, k) = map(int, sys.stdin.readline().split())
line = sys.stdin.readline()
start = line.index('G')
end = line.index('T')
if start <= end:
	line = line[start:end + 1:k]
else:
	line = line[end:start + 1:k]
if line.count('T') < 1 or line.count('G') < 1 or line.count('#') > 0:
	sys.stdout.write('NO')
else:
	sys.stdout.write('YES')


import math, sys, re, itertools, pprint, collections, copy
(rs, ri, rai, raf) = (input, lambda : int(input()), lambda : list(map(int, input().split())), lambda : list(map(float, input().split())))
(n, k) = rai()
s = input()
(g, t) = (s.index('G'), s.index('T'))
d = 1 if t >= g else -1
ch = s[g]
while g != t:
	g += d * k
	if g >= len(s) or g < 0 or s[g] == '#':
		ch = None
		break
	ch = s[g]
print('YES' if ch == 'T' else 'NO')


(n, k) = map(int, input().split())
s = input()
current = s.index('G')
finish = s.index('T')
if current < finish:
	while current != finish:
		current += k
		if current >= n:
			print('NO')
			break
		elif current == finish:
			print('YES')
			break
		elif s[current] == '#':
			print('NO')
			break
else:
	while current != finish:
		current -= k
		if current < 0:
			print('NO')
			break
		elif current == finish:
			print('YES')
			break
		elif s[current] == '#':
			print('NO')
			break


def check(c, start, end, k):
	for i in range(start, end + 1, k):
		if i == end:
			return 'YES'
		if c[i] == '#':
			return 'NO'
	return 'NO'
(n, k) = map(int, input().split())
c = input()
start = c.index('G')
end = c.index('T')
dist = abs(start - end)
if start == end:
	print('YES')
elif dist < k:
	print('NO')
elif start < end:
	print(check(c, start, end, k))
else:
	print(check(c, end, start, k))


(n, jumps) = map(int, input().split())
s = input()
i = s.index('T') + 1
j = s.index('G') + 1
d = abs(i - j)
mi = min(i, j)
ma = max(i, j)
d1 = ma - mi
if not d1 % jumps:
	for k in range(mi - 1, ma, jumps):
		p = True
		if s[k] == '#':
			p = False
			break
	if p:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
i = s.find('G')
ans = False
while i < n:
	if s[i] == '#':
		break
	if s[i] == 'T':
		ans = True
		break
	i += k
i = s.find('G')
while i > -1:
	if s[i] == '#':
		break
	if s[i] == 'T':
		ans = True
		break
	i -= k
if ans:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split(' '))
field = input()
flag = True
distance = field.find('T') - field.find('G')
if abs(distance) % k != 0:
	flag = False
else:
	direction = distance > 0
	for i in range(field.find('G'), field.find('T'), k if direction else -k):
		flag = flag and field[i] != '#'
print('YES' if flag else 'NO')


(n, k) = list(map(int, input().split()))
s = list(input())
if s.index('T') < s.index('G'):
	s.reverse()
for i in range(s.index('G'), len(s), k):
	if s[i] == '#':
		print('No')
		break
	if s[i] == 'T':
		print('Yes')
		break
else:
	print('No')


(n, k) = list(map(int, input().split()))
string = input()
good = False
answer = True
counter = 0
while True:
	if counter >= n:
		answer = False
		break
	if not good and string[counter] in 'GT':
		good = True
		counter += k
	elif not good:
		counter += 1
	else:
		if string[counter] == '#':
			answer = False
		if string[counter] in 'GT':
			break
		counter += k
if answer:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input().strip()
m = min(s.index('G'), s.index('T'))
flag = 0
for i in range(m + k, n, k):
	if s[i] == '#':
		flag = 1
		print('NO')
		break
	if s[i] == 'G' or s[i] == 'T':
		flag = 1
		print('YES')
		break
if flag == 0:
	print('NO')


(n, k) = map(int, input().split())
a = input()
g = 1
(l, r) = (a.index('G'), a.index('T'))
if l > r:
	(l, r) = (r, l)
while l + k <= r:
	if a[l] == '#':
		g = 0
	l += k
if l == r and g:
	print('YES')
else:
	print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return abs(a // gcd(a, b) * b)

def primesbelow(N):
	correction = N % 6 > 1
	N = {0: N, 1: N - 1, 2: N + 4, 3: N + 3, 4: N + 2, 5: N + 1}[N % 6]
	sieve = [True] * (N // 3)
	sieve[0] = False
	for i in range(int(N ** 0.5) // 3 + 1):
		if sieve[i]:
			k = 3 * i + 1 | 1
			sieve[k * k // 3::2 * k] = [False] * ((N // 6 - k * k // 6 - 1) // k + 1)
			sieve[(k * k + 4 * k - 2 * k * (i % 2)) // 3::2 * k] = [False] * ((N // 6 - (k * k + 4 * k - 2 * k * (i % 2)) // 6 - 1) // k + 1)
	return [2, 3] + [3 * i + 1 | 1 for i in range(1, N // 3 - correction) if sieve[i]]
smallprimeset = set(primesbelow(100000))

def solve():
	(n, m) = sep()
	s = inp()
	g = s.index('G')
	t_i = s.index('T')
	t = -1
	for i in range(g, t_i + 1, m):
		if s[i] == '#':
			break
		elif s[i] == 'T':
			t = 1
			break
	if t == -1:
		for i in range(g, t_i - 1, -m):
			if s[i] == '#':
				break
			elif s[i] == 'T':
				t = 1
				break
	if t == 1:
		print('YES')
	else:
		print('NO')
solve()


def solution(l1, l2):
	n = l1[0]
	k = l1[1]
	if l2.index('G') < l2.index('T'):
		(lower, upper) = ('G', 'T')
	else:
		(lower, upper) = ('T', 'G')
	slizey = l2[min(l2.index(lower), l2.index(upper)):max(l2.index(lower), l2.index(upper)) + 1]
	i = 0
	if (l2.index(upper) - l2.index(lower)) % k:
		return 'NO'
	while i < len(slizey):
		if slizey[i] == '#':
			return 'NO'
		i += k
	return 'YES'

def answer():
	l1 = [int(x) for x in input().split()]
	l2 = list(input())
	print(solution(l1, l2))
answer()


[n, k] = list(map(int, input().split()))
s = input()

def dfs(v):
	vis[v] = 1
	res = False
	if s[v] == 'T':
		return True
	if v + k < n and vis[v + k] == 0 and (s[v + k] != '#'):
		res |= dfs(v + k)
	if v - k >= 0 and vis[v - k] == 0 and (s[v - k] != '#'):
		res |= dfs(v - k)
	return res
vis = [0 for i in range(n)]
for i in range(n):
	if s[i] == 'G':
		if dfs(i) == True:
			print('YES')
			exit(0)
		else:
			print('NO')
			exit(0)


(n, k) = map(int, input().split())
s = input()
(l, r) = (s.find('T'), s.find('G'))
(l, r) = (min(l, r), max(l, r))
print('YES' if '#' not in s[l + k:r:k] and (r - l) % k == 0 else 'NO')


(n, k) = map(int, input().split())
s = input()
i1 = s.index('G')
i2 = s.index('T')
if i1 > i2:
	(i1, i2) = (i2, i1)
if '#' in s[i1:i2:k] or (i2 - i1) % k:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
pos_G = s.index('G')
pos_T = s.index('T')
if pos_T < pos_G:
	(pos_G, pos_T) = (pos_T, pos_G)
if (pos_T - pos_G) % k != 0:
	print('No')
else:
	while pos_G < pos_T:
		if s[pos_G + k] == '#':
			print('No')
			break
		elif s[pos_G + k] == 'T' or s[pos_G + k] == 'G':
			print('Yes')
			break
		else:
			pos_G = pos_G + k


(n, k) = map(int, input().split())
s = input()
if s.index('G') < s.index('T'):
	s = list(reversed(s))
y = list(reversed(s[s.index('T'):s.index('G') + 1]))
if (len(y) - 1) % k == 0:
	for i in range(k, len(y), k):
		if y[i] == '#':
			print('NO')
			exit()
		if y[i] == 'T':
			print('YES')
			exit()
print('NO')


(n, k) = [int(i) for i in input().split()]
s = input()
iG = 0
iT = 0
for i in range(0, n):
	if s[i] == 'G':
		iG = i
	if s[i] == 'T':
		iT = i
l = min(iG, iT)
r = max(iG, iT)
if (r - l) % k != 0:
	print('NO')
	exit(0)
while r != l:
	l += k
	if s[l] == '#':
		print('NO')
		exit(0)
print('YES')


(n, m) = map(int, input().split())
a = list(input())
place = a[min(a.index('G'), a.index('T')):max(a.index('T'), a.index('G')) + 1:m]
print('NO' if '#' in place or 'T' not in place or 'G' not in place else 'YES')


(n, k) = map(int, input().split())
lst = list(input())
kuzne4ik = lst.index('G')
tarakan = lst.index('T')
if kuzne4ik < tarakan:
	while True:
		kuzne4ik += k
		if kuzne4ik > n - 1:
			print('NO')
			exit()
		if lst[kuzne4ik] == 'T':
			print('YES')
			exit()
		if lst[kuzne4ik] == '#':
			print('NO')
			exit()
else:
	while True:
		if kuzne4ik < 0:
			print('NO')
			exit()
		kuzne4ik -= k
		if lst[kuzne4ik] == '#':
			print('NO')
			exit()
		if lst[kuzne4ik] == 'T':
			print('YES')
			exit()


(n, k) = map(int, input().split())
s = list(input())
(g, t, f) = (s.index('G'), s.index('T'), 0)
if abs(g - t) >= k and abs(g - t) % k == 0:
	for x in range(min(g, t) + k, max(g, t), k):
		if s[x] == '#':
			f = 1
			break
else:
	f = 1
if f == 0:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
polosa = input()
pos = 0
for v in polosa:
	if v == 'G':
		pos_kz = pos
	elif v == 'T':
		pos_mo = pos
	else:
		pass
	pos += 1
answer = 'NO'
if pos_mo > pos_kz:
	for m in range(n):
		pos_kz += k
		if pos_kz == pos_mo:
			answer = 'YES'
			break
		elif pos_kz >= n:
			answer = 'NO'
			break
		elif polosa[pos_kz] == '#':
			answer = 'NO'
			break
		else:
			pass
else:
	for m in range(n):
		pos_kz -= k
		if pos_kz == pos_mo:
			answer = 'YES'
			break
		elif pos_kz <= 0:
			answer = 'NO'
			break
		elif polosa[pos_kz] == '#':
			answer = 'NO'
			break
		else:
			pass
print(answer)


def solve():
	(n, k) = map(int, input().split())
	line = input()
	(g, t) = (line.find('G'), line.find('T'))
	hop = k * (-1 if g > t else 1)
	while g >= 0 and g < len(line):
		if line[g] == '#':
			print('NO')
			return
		elif line[g] == 'T':
			print('YES')
			return
		g += hop
	print('NO')
solve()


from sys import stdin
from sys import stdout

def main():
	(n, k) = (int(x) for x in stdin.readline().split())
	l = list(stdin.readline().strip())
	gPosition = 0
	tPosition = 0
	for (i, c) in enumerate(l):
		if c == 'G':
			gPosition = i
		if c == 'T':
			tPosition = i
	if tPosition < gPosition:
		k = -k
	if (tPosition - gPosition) % k != 0:
		stdout.write('NO')
		return
	for i in range(gPosition, tPosition, k):
		if l[i] == '#':
			stdout.write('NO')
			return
	stdout.write('YES')
main()


(n, k) = [int(x) for x in input().split()]
s = input()
a = s.find('G')
b = s.find('T')
d = abs(a - b)
if d % k != 0:
	print('NO')
else:
	flag = True
	if a > b:
		for i in range(a, b, -k):
			if s[i] == '#':
				print('NO')
				flag = False
				break
	elif a < b:
		for i in range(a, b, k):
			if s[i] == '#':
				print('NO')
				flag = False
				break
	if flag:
		print('YES')


(n, k) = map(int, input().split())
s = str(input())
g = s.index('G')
t = s.index('T')
if abs(g - t) % k != 0:
	print('NO')
	exit()
else:
	x = abs(g - t) // k
	i = min(g, t)
	l = []
	for j in range(1, x + 1):
		l.append(i + j * k)
		if s[j * k + i] == '#':
			print('NO')
			exit()
print('YES')


(n, k) = map(int, input().split())
s = input()
x = s.index('G')
y = s.index('T')
if '#' in s:
	z = s.index('#')
flag = 0
if x > y:
	if (x - y) % k == 0:
		for i in range(y, x):
			if s[i] == '#' and (x - i) % k == 0:
				print('NO')
				flag = 1
				break
			elif i == x - 1:
				flag = 1
				print('YES')
				break
elif x < y:
	if (y - x) % k == 0:
		for i in range(x, y):
			if s[i] == '#' and (i - x) % k == 0:
				print('NO')
				flag = 1
				break
			elif i == y - 1:
				flag = 1
				print('YES')
				break
if flag == 0:
	print('NO')


def getLnInput():
	return input().split()

def ceilDivision(a, b):
	return (a - 1) // b + 1

def main():
	(n, k) = list(map(int, getLnInput()))
	cells = getLnInput()[0]
	g = cells.find('G')
	t = cells.find('T')
	if g > t:
		cells = cells[::-1]
		g = cells.find('G')
		t = cells.find('T')
	if (t - g) % k == 0:
		while g != t:
			if cells[g + k] != '#' and g + k < n:
				g += k
			else:
				break
		if g == t:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	return
main()


import sys
(n, k) = map(int, input().split())
s = input()
isgoon = True
index = 0
ans = 'NO'
for i in range(n):
	if s[i] == 'G':
		index = i
		break
	elif s[i] == 'T':
		index = i
		break
if isgoon == True:
	while index < n - k and isgoon == True:
		if s[index + k] == '.':
			index += k
		elif s[index + k] == '#':
			isgoon = False
		elif s[index + k] == 'T' or s[index + k] == 'G':
			ans = 'YES'
			isgoon = False
print(ans)


(n, k) = map(int, input().split())
way = input()
a = way.find('G')
b = way.find('T')
f = 1
if (b - a) % k == 0:
	m = (b - a) / k
	if m > 0:
		while way[a + k * f] == '.':
			f += 1
		if f == m:
			print('YES')
		else:
			print('NO')
	if m < 0:
		while way[a - k * f] == '.':
			f += 1
		if f == abs(m):
			print('YES')
		else:
			print('NO')
else:
	print('NO')


(n, k) = map(int, input().split())
l = list(input())
g = l.index('G')
t = l.index('T')
if g > t:
	flag = 0
	for i in range(g - k, t - 1, -k):
		if l[i] == '#':
			flag = 1
			print('no')
			break
		elif l[i] == '.':
			continue
		else:
			flag = 1
			print('yes')
			break
	if flag == 0:
		print('no')
else:
	flag = 0
	for i in range(g + k, t + 1, k):
		if l[i] == '#':
			flag = 1
			print('no')
			break
		elif l[i] == '.':
			continue
		else:
			flag = 1
			print('yes')
			break
	if flag == 0:
		print('no')


(n, k) = map(int, input().split())
line = input()
(s, t) = [i for (i, x) in enumerate(line) if x in 'GT']
if (t - s) % k:
	print('NO')
else:
	while s < t:
		if line[s] == '#':
			print('NO')
			break
		s += k
	else:
		print('YES')


(n, k) = map(int, input().split())
s = input()
i = 0
st = -1

def jump(st):
	while st < n:
		st += k
		if st >= n or s[st] == '#':
			return 'NO'
		if s[st] == 'T' or s[st] == 'G':
			return 'YES'
	return 'NO'
while i < n:
	if s[i] == 'T' or s[i] == 'G':
		if st == -1:
			st = i
			break
	i += 1
print(jump(st))


def solve(n, k, line):
	pos = line.index('G')
	posT = line.index('T')
	if posT < pos:
		k = -1 * k
	while (pos < n and pos >= 0) and line[pos] != '#':
		if line[pos] == 'T':
			print('YES')
			return
		pos += k
	print('NO')

def main():
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	line = input()
	solve(n, k, line)
main()


(n, k) = list(map(int, input().split(' ')))
board = list(input())
g_index = board.index('G')
t_index = board.index('T')
board = g_index > t_index and list(reversed(board)) or board
g_index = board.index('G')
t_index = board.index('T')
while True:
	g_index += k
	if g_index >= len(board) or g_index == t_index or board[g_index] != '.':
		break
print(g_index == t_index and 'YES' or 'NO')


(n, k) = input().split(' ')
st = input()
(g, t) = (st.index('G'), st.index('T'))
if g > t:
	i = g - t
	st = st[::-1]
	(g, t) = (st.index('G'), st.index('T'))
else:
	i = t - g
if i % int(k) == 0:
	j = g
	while j in range(g, t):
		if st[j] == '#':
			print('NO')
			break
		else:
			j += int(k)
		if st[j] == 'T':
			print('YES')
			break
else:
	print('NO')


((n, k), s) = (map(int, input().split()), input())
for i in range(min(s.find('G'), s.find('T')) + k, n, k):
	if s[i] == '#':
		print('NO')
		break
	if s[i] in 'GT':
		print('YES')
		break
else:
	print('NO')


def get_ans(n, k, l, g, t):
	if t < g:
		i = g - k
		while i >= t:
			if l[i] == '#':
				break
			if l[i] == 'T':
				return 'YES'
			i = i - k
		return 'NO'
	else:
		i = g
		while i <= t:
			if l[i] == '#':
				break
			if l[i] == 'T':
				return 'YES'
			i = i + k
		return 'NO'
(n, k) = list(map(int, str(input()).strip().split()))
s = str(input()).strip()
l = [s[i] for i in range(len(s))]
g = l.index('G')
t = l.index('T')
print(get_ans(n, k, l, g, t))


def main():
	try:
		while True:
			(n, k) = map(int, input().split())
			s = input()
			g = s.index('G')
			t = s.index('T')
			if t < g:
				k = -k
			while 0 <= g < n:
				if s[g] == 'T':
					print('YES')
					break
				if s[g] == '#':
					print('NO')
					break
				g += k
			else:
				print('NO')
	except EOFError:
		pass
main()


(n, k) = map(int, input().split())
s = input()
s_t = set(['G', 'T'])
p = 0
for i in range(len(s)):
	if s[i] in s_t:
		p = i
		break
p += k
while p < len(s):
	if s[p] in s_t:
		print('YES')
		quit()
	elif s[p] == '#':
		print('NO')
		quit()
	p += k
print('NO')


(n, k) = map(int, input().split())
arr = list(input())
pos = arr.index('G')
target = arr.index('T')
if pos > target:
	flag = 0
	for i in range(pos, target - 1, -k):
		if arr[i] == '#':
			flag = 0
			break
		elif arr[i] == 'T':
			flag = 1
			break
		else:
			continue
	if flag == 0:
		print('NO')
	else:
		print('YES')
else:
	flag = 0
	for i in range(pos, target + 1, k):
		if arr[i] == '#':
			flag = 0
			break
		elif arr[i] == 'T':
			flag = 1
			break
		else:
			continue
	if flag == 0:
		print('NO')
	else:
		print('YES')


(n, k) = [int(x) for x in input().split()]
s = input()
(start, target) = (0, 0)
for (i, c) in enumerate(s):
	if c == 'G':
		start = i
	if c == 'T':
		target = i
visited = set()

def dfs(i):
	if i in visited:
		return False
	if i == target:
		return True
	if not 0 <= i < len(s) or s[i] == '#':
		return False
	visited.add(i)
	return dfs(i - k) or dfs(i + k)
print('YES' if dfs(start) else 'NO')


(n, m) = map(int, input().split())
s = input()
x = s.find('G')
y = s.find('T')
if x > y:
	(x, y) = (y, x)
if (y - x) % m == 0:
	for i in range(x + m, y, m):
		if s[i] == '#':
			print('NO')
			break
	else:
		print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
ind_G = s.find('G')
ind_T = s.find('T')
Stop = False
if abs(ind_G - ind_T) % k != 0:
	print('NO')
else:
	(ind_G, ind_T) = (min(ind_G, ind_T), max(ind_G, ind_T))
	i = ind_G
	i += k
	while i != ind_T and (not Stop):
		if s[i] == '.':
			i += k
		else:
			Stop = True
	if Stop:
		print('NO')
	else:
		print('YES')


import sys

def find_first(line):
	for char in line:
		if char == 'G':
			return True
		elif char == 'T':
			return False

def find_gh(line):
	for i in range(len(line)):
		if line[i] == 'G':
			return i

def gh_solver(num_of_cells, jump, line):
	assert num_of_cells == len(line)
	right = find_first(line)
	gh_index = find_gh(line)
	if right:
		while True:
			gh_index += jump
			if gh_index >= len(line) or line[gh_index] == '#':
				return False
			elif line[gh_index] == 'T':
				return True
	else:
		while True:
			gh_index -= jump
			if gh_index < 0 or line[gh_index] == '#':
				return False
			elif line[gh_index] == 'T':
				return True

def main():
	(num_of_cells, jump) = [int(i) for i in str(sys.stdin.readline()).split(' ')]
	input_line = str(sys.stdin.readline())
	if gh_solver(num_of_cells, jump, input_line[:len(input_line) - 1]):
		print('YES')
	else:
		print('NO')
main()


def solution():
	(n, k) = map(int, input().split())
	ways = input()
	gi = ways.index('G')
	ti = ways.index('T')
	dis = abs(gi - ti)
	r = dis % k
	if r != 0:
		print('NO')
		return
	q = dis // k
	if gi < ti:
		for i in range(q):
			if ways[gi + i * k] == '#':
				print('NO')
				return
	else:
		for i in range(q):
			if ways[gi - i * k] == '#':
				print('NO')
				return
	print('YES')
solution()


(n, k) = list(map(int, input().split()))
s = input()
g = s.index('G')
t = s.index('T')
if g > t:
	(g, t) = (t, g)
if (t - g) % k:
	print('NO')
elif '#' in s[g + k:t:k]:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
a = []
g = 0
t = 0
for i in range(n):
	if s[i] == '#':
		a.append(i)
	if s[i] == 'G':
		g = i
	if s[i] == 'T':
		t = i
if abs((t - g) % k != 0):
	print('NO')
	raise SystemExit
if t > g:
	for i in range(g, t, k):
		if i in a:
			print('NO')
			raise SystemExit
else:
	for i in range(t, g, k):
		if i in a:
			print('NO')
			raise SystemExit
print('YES')


(n, k) = map(int, input().split())
s = input()
(g, t, l) = (s.index('G'), s.index('T'), len(s))
if t >= g:
	while g < l:
		g += k
		if g >= l:
			print('NO')
			break
		if s[g] == '#':
			print('NO')
			break
		if s[g] == 'T':
			print('YES')
			break
else:
	while g >= 0:
		g -= k
		if g < 0:
			print('NO')
			break
		if s[g] == '#':
			print('NO')
			break
		if s[g] == 'T':
			print('YES')
			break


(n, k) = map(int, input().split())
path = input()
start = path.find('G')
finish = path.find('T')
if start > finish:
	for i in range(start, -1, -k):
		if path[i] == 'T':
			print('YES')
			exit()
		if path[i] == '#':
			print('NO')
			exit()
	print('NO')
	exit()
else:
	for i in range(start, n, k):
		if path[i] == 'T':
			print('YES')
			exit()
		if path[i] == '#':
			print('NO')
			exit()
	print('NO')
	exit()


(n, k) = map(int, input().split())
a = input()
(x, y) = sorted([a.index('G'), a.index('T')])
print('YNEOS'[x % k != y % k or any((a[x] == '#' for x in range(x, y, k)))::2])


def solve(s, k):
	i = min(s.index('G'), s.index('T')) + k
	while i < len(s):
		if s[i] == '#':
			return 'NO'
		if s[i] in ['G', 'T']:
			return 'YES'
		i += k
	return 'NO'
(n, k) = map(int, input().split())
print(solve(input(), k))


(n, k) = list(map(int, input().split()))
s = input()
sp = s.find('G')
en = s.find('T')
if sp > en:
	for i in range(sp, -n, -k):
		if s[i] == '#':
			print('NO')
			break
		elif s[i] == 'T':
			print('YES')
			break
		else:
			continue
	else:
		print('NO')
else:
	for i in range(sp, n, k):
		if s[i] == '#':
			print('NO')
			break
		elif s[i] == 'T':
			print('YES')
			break
		else:
			continue
	else:
		print('NO')


def sign(x):
	return 1 if x >= 0 else -1

def solve():
	(n, k) = tuple(map(int, input().split()))
	cells = list(input())
	start = cells.index('G')
	end = cells.index('T')
	direction = sign(end - start)
	for x in range(start, end + direction, direction * k):
		if cells[x] == '#':
			return False
	if not cells[x] == 'T':
		return False
	return True

def output(f):
	return 'YES' if f() else 'NO'
print(output(solve))


from sys import stdin
(n, k) = list(map(int, stdin.readline().split()))
s = stdin.readline().strip()
index = s.find('G')
index2 = s.find('T')
if index > index2:
	s = ''.join(reversed(s))
index = s.find('G') + k
while index < n:
	if s[index] == 'T':
		print('YES')
		break
	if s[index] == '#':
		print('NO')
		break
	index += k
else:
	print('NO')


(n, k) = map(int, input().split())
c = list(input())
(a, b) = (c.index('G'), c.index('T'))
(a, b) = (min(a, b), max(a, b))
print('YES' if (b - a) % k == 0 and '#' not in c[a:b + 1:k] else 'NO')


(n, k) = input().split()
(n, k) = map(int, [n, k])
s = input()
A = []
for i in s:
	A.append(i)
a = A.index('T')
b = A.index('G')
c = 0
if (b - a) % k != 0:
	c = 1
elif b < a and a - b >= k:
	for j in range(b + k, a, k):
		if A[j] == '#':
			c = 1
			break
elif b > a and b - a >= k:
	for l in range(a + k, b, k):
		if A[l] == '#':
			c = 1
			break
if c == 1:
	print('NO')
else:
	print('YES')


def solve(length, k, array):
	g = 0
	t = 0
	i = 0
	while i < length:
		if array[i] == 'G':
			g = i
		elif array[i] == 'T':
			t = i
		i += 1
	if (g - t) % k != 0:
		print('NO')
		return
	dir = 1
	if g > t:
		dir = -1
	while g != t:
		g += dir * k
		if array[g] == '#':
			print('NO')
			return
	print('YES')
	return

def main():
	x = tuple(map(int, input().rstrip().split()))
	array = input().rstrip()
	solve(x[0], x[1], array)
main()


def solve(str, n, k):
	g = str.index('G')
	t = str.index('T')
	if g > t:
		for i in range(t, g + 1, k):
			if str[i] == 'G':
				return True
			if str[i] == '#':
				return False
	else:
		for i in range(g, t + 1, k):
			if str[i] == 'T':
				return True
			if str[i] == '#':
				return False
	return False
strnk = input()
str1 = strnk.split(' ')
n = int(str1[0])
k = int(str1[1])
str = input()
if solve(str, n, k) == True:
	print('YES')
else:
	print('NO')


def main():
	from sys import stdin, stdout
	(n, k) = list(map(int, stdin.readline().split()))
	s = stdin.readline().strip()
	g = s.index('G')
	t = s.index('T')
	if abs(t - g) % k:
		stdout.write('NO')
	else:
		minim = min(t, g)
		maxim = max(t, g)
		flag = 1
		while minim < maxim:
			if s[minim] == '#':
				flag = 0
				break
			minim += k
		if flag:
			stdout.write('YES')
		else:
			stdout.write('NO')

def __starting_point():
	main()
__starting_point()


from collections import deque
(n, k) = map(int, input().split())
line = list(input())
queue = deque()
for (idx, i) in enumerate(line):
	if i == 'G':
		queue.append(idx)
		line[idx] = '#'
res = False
while len(queue) > 0:
	el = queue.popleft()
	if el - k >= 0 and line[el - k] != '#':
		queue.append(el - k)
		if line[el - k] == 'T':
			res = True
			break
		line[el - k] = '#'
	if el + k < n and line[el + k] != '#':
		queue.append(el + k)
		if line[el + k] == 'T':
			res = True
			break
		line[el + k] = '#'
print('YES' if res else 'NO')


(n, k) = map(int, input().split(' '))
s = input()
if s.index('G') > s.index('T'):
	s = s[::-1]
for i in range(s.index('G'), n, k):
	if s[i] == 'T':
		print('YES')
		break
	elif s[i] == '#':
		print('NO')
		break
else:
	print('NO')


import sys
lines = [line.strip() for line in sys.stdin]
(n, k) = map(int, lines[0].split(' '))
maze = lines[1]
start = maze.index('G')
end = maze.index('T')
offset = abs(start - end)
lessThan = None
while True:
	if start < 0 or start >= n:
		print('NO')
		sys.exit(0)
	if maze[start] == '#':
		print('NO')
		sys.exit(0)
	if start == end:
		print('YES')
		sys.exit(0)
	if start < end:
		start += k
		if start > end:
			print('NO')
			sys.exit(0)
	else:
		start -= k
		if start < end:
			print('NO')
			sys.exit(0)


(n, k) = list(map(int, input().split()))
s = input()
g = s.find('G')
t = s.find('T')
if t > g:
	if t != len(s) - 1:
		s = s[g:t + 1:k]
	else:
		s = s[g::k]
elif t != 0:
	s = s[g:t - 1:-k]
else:
	s = s[g::-k]
if s.count('#') == 0 and s.find('T') != -1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
ok = True
strt = min(s.find('G'), s.find('T'))
des = max(s.find('G'), s.find('T'))
if (des - strt) % k != 0:
	ok = False
while strt < des:
	if s[strt] == '#':
		ok = False
		break
	strt += k
if ok:
	print('YES')
else:
	print('NO')


import sys
import math
import time
(n, k) = [int(j) for j in input().split()]
s = input()
g = s.index('G')
h = False
for i in range(g, -1, -k):
	if s[i] == '#':
		h = True
	if s[i] == 'T':
		print('NO' if h else 'YES')
		exit()
h = False
for i in range(g, len(s), k):
	if s[i] == '#':
		h = True
	if s[i] == 'T':
		print('NO' if h else 'YES')
		exit()
print('NO')


def find_first(mystr):
	p1 = int(mystr.index('G'))
	p2 = int(mystr.index('T'))
	diff = abs(p1 - p2)
	if p1 < p2:
		return (p1, diff)
	else:
		return (p2, diff)

def grasshopper_ostap(mystr, k):
	if mystr is None or k is None or k is 0:
		return 'NO'
	(f1, f2) = (False, False)
	(pos, diff) = find_first(mystr)
	if diff % k != 0:
		return 'NO'
	cnt = 0
	for i in range(pos, len(mystr), k):
		if mystr[i] == '#':
			return 'NO'
		elif mystr[i] == 'G':
			cnt += 1
			f1 = True
			if cnt == 2:
				break
		elif mystr[i] == 'T':
			cnt += 1
			f2 = True
			if cnt == 2:
				break
	if f1 and f2:
		return 'YES'
	else:
		return 'NO'
(_, k) = map(int, input().split())
print(grasshopper_ostap(str(input()), k))


(n, k) = map(int, input().split())
s1 = str(input())
s = list((i for i in s1))
for i in range(n):
	if s[i] == 'G' and i + k < n:
		if s[i + k] == '#':
			break
		if s[i + k] == 'T':
			print('YES')
			exit()
		s[i + k] = 'G'
for i in range(n):
	if s[-i - 1] == 'G' and -1 - i - k >= -n:
		if s[-i - 1 - k] == '#':
			break
		if s[-i - 1 - k] == 'T':
			print('YES')
			exit()
		s[n - i - 1 - k] = 'G'
print('NO')


from sys import stdin, stdout

def solve():
	(n, k) = map(int, stdin.readline().strip().split())
	s = stdin.readline().strip()
	a = s.index('G')
	b = s.index('T')
	if abs(a - b) % k != 0:
		print('NO')
		return
	if a > b:
		(a, b) = (b, a)
	for i in range(a, b + 1, k):
		if s[i] == '#':
			print('NO')
			return
	print('YES')
for i in range(1):
	solve()


from sys import stdin, stdout

def main():
	temp = input().split()
	cells = input()
	length = int(temp[0])
	jumpLength = int(temp[1])
	startPos = None
	for x in range(0, length):
		if cells[x] == 'G' or cells[x] == 'T':
			startPos = x
			break
	currPos = startPos + jumpLength
	result = False
	while currPos < length:
		if cells[currPos] == 'G' or cells[currPos] == 'T':
			result = True
			break
		if cells[currPos] == '#':
			result = False
			break
		currPos = currPos + jumpLength
	if result:
		print('YES')
	else:
		print('NO')
main()


def main():
	(n, k) = map(int, input().split())
	s = input()
	(g, t) = (s.find('G'), s.find('T'))
	if g < t:
		s = s[g:t + 1:k]
	else:
		s = s[t:g + 1:k][::-1]
	print(('NO', 'YES')[s[0] == 'G' and s[-1] == 'T' and ('#' not in s)])
main()


def compute_indices_between(g, t, jump_size):
	diff = g - t
	indices = []
	if diff > 0:
		while g > t:
			indices.append(g - jump_size)
			g -= jump_size
	else:
		while g < t:
			indices.append(g + jump_size)
			g += jump_size
	return indices

def solve(jump_size, cells):
	g_index = cells.index('G')
	t_index = cells.index('T')
	diff = abs(g_index - t_index)
	if diff % jump_size > 0:
		return 'NO'
	indices = compute_indices_between(g_index, t_index, jump_size)
	for i in indices:
		if cells[i] == '#':
			return 'NO'
	return 'YES'

def main():
	(_, length_of_jump) = input().split()
	cells = input()
	answer = solve(int(length_of_jump), cells)
	print(answer)
	return answer
main()


(n, k) = map(int, input().split())
line = input()
for x in range(n):
	if line[x] == 'G':
		g = x
	elif line[x] == 'T':
		t = x
if (g - t) % k == 0:
	if g > t:
		while g > t:
			if g - k == t:
				print('YES')
				exit()
			elif line[g - k] == '#':
				print('NO')
				exit()
			else:
				g = g - k
	else:
		while g < t:
			if g + k == t:
				print('YES')
				exit()
			elif line[g + k] == '#':
				print('NO')
				exit()
			else:
				g = g + k
else:
	print('NO')
	exit()


(n, k) = map(int, input().split())
s = input()
a = s.find('G')
b = s.find('T')
if abs(a - b) % k != 0:
	print('NO')
else:
	f = 1
	for i in range(min(a, b), max(a, b) + 1, k):
		if s[i] == '#':
			f = 0
			print('NO')
			break
	if f == 1:
		print('YES')


def main():
	(n, k) = list(map(int, input().split()))
	a = input()
	l = 0
	r = 0
	for i in range(n):
		if a[i] == 'G':
			l = i
		elif a[i] == 'T':
			r = i
	if l < r:
		if (r - l) % k == 0:
			for i in range(l, r + 1, k):
				if a[i] == '#':
					print('NO')
					return
			print('YES')
		else:
			print('NO')
	elif (r - l) % k == 0:
		for i in range(r, l + 1, k):
			if a[i] == '#':
				print('NO')
				return
		print('YES')
	else:
		print('NO')
main()


(n, k) = list(map(int, input().strip().split()))
a = input()
t = a.index('G')
p = a.index('T')
if t == p:
	print('YES')
elif p > t:
	for i in range(t, n, k):
		if a[i] == 'T':
			print('YES')
			break
		elif a[i] == '#':
			print('NO')
			break
		else:
			pass
	else:
		print('NO')
else:
	a = a[::-1]
	t = n - t - 1
	for i in range(t, n, k):
		if a[i] == 'T':
			print('YES')
			break
		elif a[i] == '#':
			print('NO')
			break
		else:
			pass
	else:
		print('NO')


(n, k) = map(int, input().split())
s = input()
grass = 0
ins = 0
a = str()
for i in range(n):
	if s[i] == 'G':
		grass = i
		break
for i in range(n):
	if s[i] == 'T':
		ins = i
		break
if (max(ins, grass) - min(ins, grass)) % k != 0:
	a = 'NO'
else:
	i = min(ins, grass)
	i += k
	j = max(ins, grass)
	while i <= j:
		if s[i] == '#':
			a = 'NO'
			break
		if s[i] == 'T':
			a = 'YES'
			break
		if s[i] == 'G':
			a = 'YES'
			break
		i += k
	else:
		a = 'NO'
print(a)


z = [int(n) for n in input().split()]
s = [n for n in input()]
a = s.index('G')
b = s.index('T')
if abs(a - b) % z[1] != 0:
	print('NO')
elif a < b:
	if s[a:b + 1].count('#') == 0:
		print('YES')
	else:
		l = 0
		for n in range(a, b):
			if s[n] == '#' and (n - a) % z[1] == 0:
				l = 1
				print('NO')
				break
		if l == 0:
			print('YES')
elif s[b:a + 1].count('#') == 0:
	print('YES')
else:
	l = 0
	for n in range(b, a):
		if s[n] == '#' and (n - b) % z[1] == 0:
			l = 1
			print('NO')
			break
	if l == 0:
		print('YES')


(n, k) = list(map(int, input().split()))
mp = input()
gg = list(mp).index('G')
tt = list(mp).index('T')
if abs(gg - tt) % k != 0:
	print('NO')
else:
	y = True
	for i in range(min([gg, tt]), max([gg, tt]) + 1, k):
		if mp[i] == '#' and y:
			print('NO')
			y = False
			break
	if y:
		print('YES')


(n, k) = [int(x) for x in input().strip().split()]
path = input().strip()
start = path.find('G')
end = path.find('T')
left = False
if end < start:
	left = True
if end == start:
	print('YES')
ok = True
if not left:
	while start < end:
		start += k
		if start > end or path[start] == '#':
			print('NO')
			ok = False
			break
	if ok:
		print('YES')
else:
	while start > end:
		start -= k
		if start < end or path[start] == '#':
			print('NO')
			ok = False
			break
	if ok:
		print('YES')


(n, x) = map(int, input().split())
s = input()
ans = 0
poka = s.find('T')
foring = s.find('G')
if poka < foring:
	for i in range(foring - x, -1, -x):
		if s[i] == '#':
			break
		elif s[i] == 'T':
			ans = 1
			break
else:
	for i in range(foring + x, n, x):
		if s[i] == '#':
			break
		elif s[i] == 'T':
			ans = 1
			break
if ans:
	print('YES')
else:
	print('NO')


import math, fractions, collections
(n, k) = [int(x) for x in input().split()]
s = str(input())
g = s.find('G')
t = s.find('T')
if g > t:
	temp = t
	t = g
	g = temp
	s = s[:g] + 'G' + s[g + 1:t] + 'T' + s[t + 1:]
flag = False
for i in range(g, t + 1, k):
	if s[i] == 'T':
		flag = True
	elif s[i] == '#':
		flag = False
		break
print('YES' if flag else 'NO')


inpLine = input()
inpLine = inpLine.split()
n = int(inpLine[0])
k = int(inpLine[1])
seq = input()
grass = -1
insect = -1
for i in range(len(seq)):
	if seq[i] == 'G':
		grass = i
	elif seq[i] == 'T':
		insect = i
	if grass != -1 and insect != -1:
		break
if grass > insect:
	for i in range(grass, insect - 1, -k):
		if i == insect:
			print('YES')
			exit()
		if seq[i] == '#':
			print('NO')
			exit()
else:
	for i in range(grass, insect + 1, k):
		if i == insect:
			print('YES')
			exit()
		if seq[i] == '#':
			print('NO')
			exit()
print('No')


(n, k) = map(int, input().split())
s = input()
a = s.index('G')
b = s.index('T')
if b > a:
	c = b - a
	if c % k != 0:
		print('NO')
	else:
		for i in range(a + k, n, k):
			if s[i] == '#':
				print('NO')
				break
			if s[i] == 'T':
				print('YES')
				break
if a > b:
	c = a - b
	if c % k != 0:
		print('NO')
	else:
		for i in range(a - k, -1, -k):
			if s[i] == '#':
				print('NO')
				break
			if s[i] == 'T':
				print('YES')
				break


f = lambda : map(int, input().split())
(n, k) = f()
s = input()
fg = 0
(g, t) = (min(s.index('G'), s.index('T')), max(s.index('G'), s.index('T')))
if abs(t - g) < k:
	exit(print('NO'))
for i in range(g, t + 1, k):
	if not s[i] in 'GT.':
		fg = 1
		break
print('YNEOS'[fg == 1 or not s[i] in 'GT'::2])


(n, k) = map(int, input().split())
s = input()
st = s.find('G')
t = s.find('T')
if abs(st - t) % k != 0:
	print('NO')
else:
	ans = 'YES'
	for i in range(min(st, t), max(st, t), k):
		if s[i] == '#':
			ans = 'NO'
			break
	print(ans)


def main():
	(n, k) = map(int, input().split())
	t = list(input())
	x1 = t.index('G')
	x2 = t.index('T')
	if x2 < x1:
		(x1, x2) = (x2, x1)
	while x1 < x2:
		if t[x1] != '#':
			x1 += k
		else:
			break
	if x1 == x2:
		print('YES')
	else:
		print('NO')
	return 0
main()


(n, k) = [int(i) for i in input().split()]
s = input()
f = s.find('G')
t = s.find('T')
if f < t:
	(f, t) = (t, f)
if (f - t) % k:
	print('NO')
else:
	for i in range(t + k, f, k):
		if s[i] == '#':
			print('NO')
			break
	else:
		print('YES')


[n, k] = [int(x) for x in input().split()]
s = input()
l = min(s.index('G'), s.index('T'))
r = max(s.index('G'), s.index('T'))
if abs(l - r) % k != 0:
	print('NO')
else:
	noObst = True
	if l == s.index('G'):
		for i in range(l, r + 1, k):
			if s[i] == '#':
				noObst = False
				break
	else:
		for i in range(r, l + 1, -k):
			if s[i] == '#':
				noObst = False
				break
	print('YES' if noObst else 'NO')


def main():
	(n, k) = map(int, input().split())
	s = input()
	x = s.find('G')
	y = s.find('T')
	if x > y:
		(x, y) = (y, x)
	for i in range(x, y + 1, k):
		if s[i] == '#':
			print('NO')
			return
	print('YES' if (y - x) % k == 0 else 'NO')
main()


def main():
	(n, k) = map(int, input().split())
	s = input()
	i_g = s.find('G')
	i_t = s.find('T')
	start = min(i_g, i_t)
	end = max(i_g, i_t)
	if (end - start) % k != 0:
		return 'NO'
	for i in range(start, end, k):
		if s[i] == '#':
			return 'NO'
	return 'YES'
print(main())


import fileinput
import sys

def main():
	(length, jump) = input('').split(' ')
	line2 = input('')
	length = int(length)
	jump = int(jump)
	position = line2.find('G')
	target = line2.find('T')
	if target > position:
		while position != target:
			if not jump <= length - 1 - position or line2[position + jump] == '#':
				break
			else:
				position = position + jump
	elif target < position:
		while position != target:
			if not jump <= position or line2[position - jump] == '#':
				break
			else:
				position = position - jump
	if position == target:
		print('YES')
	else:
		print('NO')
main()


(n, k) = map(int, input().split())
s = input()
(g, t) = (0, 0)
for i in range(len(s)):
	if s[i] == 'G':
		g = i
	if s[i] == 'T':
		t = i
if (t - g) % k == 0:
	if t > g:
		i = g
		B = True
		while i < t:
			if s[i] == '#':
				B = False
				break
			i += k
	else:
		i = t
		B = True
		while i < g:
			if s[i] == '#':
				B = False
				break
			i += k
	if B:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, k) = input().split(' ')
st = input()
(g, t) = (st.index('G'), st.index('T'))
if g > t:
	i = g - t
	st = st[::-1]
	(g, t) = (st.index('G'), st.index('T'))
else:
	i = t - g
if i % int(k) == 0:
	if '#' in st[g:t:int(k)]:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


line1 = input()
n = int(line1.split(' ')[0])
k = int(line1.split(' ')[1])
line2 = input()
count = 0
for ch in line2:
	if ch == 'G':
		g_pos = count
	if ch == 'T':
		t_pos = count
	count += 1
if g_pos < t_pos:
	result = 1
	diff = t_pos - g_pos
	if diff % k != 0:
		print('NO')
		result = 0
	if result == 1:
		try_pos = g_pos
		while try_pos != t_pos:
			try_pos += k
			if line2[try_pos] == '#':
				result = 0
				print('NO')
				break
	if result == 1:
		print('YES')
if g_pos > t_pos:
	result = 1
	diff = g_pos - t_pos
	if diff % k != 0:
		print('NO')
		result = 0
	if result == 1:
		try_pos = t_pos
		while try_pos != g_pos:
			try_pos += k
			if line2[try_pos] == '#':
				result = 0
				print('NO')
				break
	if result == 1:
		print('YES')


usr_in = input().split()
cells = input()
step = int(usr_in[1])
i = 0
while cells[i] != 'T' and cells[i] != 'G':
	i += 1
i += step
while i < len(cells) and cells[i] == '.':
	i += step
if i < len(cells) and (cells[i] == 'T' or cells[i] == 'G'):
	print('YES')
else:
	print('NO')


num = [int(n) for n in input().split()]
s = input()
l = list(s)
if l.index('T') < l.index('G'):
	l = l[::-1]
pos = l.index('G')
while pos < l.index('T') and l[pos] != '#':
	pos = pos + num[1]
if pos >= num[0]:
	print('NO')
elif l[pos] == 'T':
	print('YES')
else:
	print('NO')


(n, k) = list(map(int, input().split(' ')))
s = input()
if s.index('G') < s.index('T'):
	p = s[s.index('G') + k::k]
else:
	p = s[s.index('G') - k::-k]
print('YES' if 'T' in p and '#' not in p[:p.index('T')] else 'NO')


def dfs(x):
	if C[x] == 'T':
		return 1
	if a[x] == 1:
		return 0
	a[x] = 1
	if C[x] == '#':
		return 0
	if x + K < N and dfs(x + K):
		return 1
	if x - K >= 0 and dfs(x - K):
		return 1
	return 0
(N, K) = map(int, input().split())
C = input()
a = [0 for i in range(N)]
start = 0
for i in range(N):
	if C[i] == 'G':
		start = i
		break
print('YES' if dfs(start) else 'NO')


import math

def solve(n, k, s):
	start = s.find('G')
	end = s.find('T')
	while start < n and start <= end:
		if start == end:
			return 'YES'
		start += k
		if start >= n:
			return 'NO'
		if s[start] == '#':
			return 'NO'
	while start >= 0 and start >= end:
		if start == end:
			return 'YES'
		start -= k
		if start < 0:
			return 'NO'
		if s[start] == '#':
			return 'NO'
	return 'NO'
(n, k) = map(int, input().split())
s = input()
print(solve(n, k, s))


(n, k) = map(int, input().split())
len_G = list(input())
a = len_G.index('G') + 1
b = len_G.index('T') + 1
c_index = [i for (i, e) in enumerate(len_G) if e == '#']
c_index = [x + 1 for x in c_index]
li = []
result = False
if a < b:
	minus = b - a
	if minus % k == 0:
		temp = a
		while temp < b:
			temp = temp + k
			if any((x in c_index for x in li)):
				result = False
				break
			if temp == b:
				result = True
				break
			li.append(temp)
if a > b:
	minus = a - b
	if minus % k == 0:
		temp = a
		while temp > b:
			temp = temp - k
			if any((x in c_index for x in li)):
				result = False
				break
			if temp == b:
				result = True
				break
			li.append(temp)
if result:
	print('YES')
else:
	print('NO')


(n, k) = list(map(int, input().split(' ')))
s = input()
(ind1, ind2) = (min(s.index('G'), s.index('T')), max(s.index('G'), s.index('T')))
while ind1 != ind2 and ind1 < n:
	if ind1 + k < n and s[ind1 + k] == '#':
		break
	ind1 += k
print('NO' if ind1 != ind2 else 'YES')


nk = input().split()
n = int(nk[0])
k = int(nk[1])
s = input()
g_ind = 0
t_ind = 0
for i in range(0, n):
	if s[i] == 'G':
		g_ind = i
	elif s[i] == 'T':
		t_ind = i
start = 0
end = 0
if g_ind < t_ind:
	start = g_ind
	end = t_ind
else:
	start = t_ind
	end = g_ind
res = True
if (end - start) % k != 0:
	res = False
else:
	while start < end:
		if s[start] == '#':
			res = False
			break
		start += k
if res:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
l = list(input())
indG = l.index('G')
target = l.index('T')
if abs(target - indG) % k != 0:
	print('NO')
	exit()
for i in range(min(indG, target), max(indG, target), k):
	if i == min(indG, target):
		continue
	if l[i] == '#':
		print('NO')
		break
else:
	print('YES')


(n, k) = map(int, input().split(' '))
s = input()
g_ind = s.index('G')
t_ind = s.index('T')
ind = g_ind
if g_ind > t_ind:
	r = 'NO'
	while ind > t_ind - 1 and s[ind] != '#':
		if ind == t_ind:
			r = 'YES'
			break
		ind -= k
	print(r)
else:
	r = 'NO'
	while ind < t_ind + 1 and s[ind] != '#':
		if ind == t_ind:
			r = 'YES'
			break
		ind += k
	print(r)


(n, k) = map(int, input().split())
a = input()
for i in range(n):
	if a[i] == 'G':
		first = i
	elif a[i] == 'T':
		last = i
if first > last:
	x = last
	last = first
	first = x
if (last - first) % k != 0:
	print('NO')
else:
	flag = 0
	for j in range(first, last, k):
		if a[j] == '#':
			flag = 1
			break
	print('YES' if flag == 0 else 'NO')


import math
(n, k) = map(int, input().split())
s = input()
x = 0
if s.index('G') > s.index('T'):
	s = s[::-1]
for i in range(s.index('G'), n, k):
	if s[i] == '#':
		x = -1
		break
	elif s[i] == 'T':
		x = 1
		break
print('YES' if x == 1 else 'NO')


(n, k) = map(int, input().split())
str = input()
count1 = 0
for i in str:
	if i == 'G':
		break
	count1 += 1
count2 = 0
for i in str:
	if i == 'T':
		break
	count2 += 1
l = list(str)
if abs(count1 - count2) % k == 0:
	pos = min(count1, count2)
	while pos != max(count1, count2):
		c = 0
		if l[pos] == '#':
			print('NO')
			c += 1
			break
		pos = pos + k
	if c == 0:
		print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
l = input()
i = l.find('G')
t = False
while i < n - k:
	i += k
	if l[i] == 'T':
		print('YES')
		t = True
		break
	elif l[i] == '#':
		break
while i > k - 1:
	i -= k
	if l[i] == 'T':
		print('YES')
		t = True
		break
	elif l[i] == '#':
		break
if t == False:
	print('NO')


(length, jump) = map(int, input().split())
line = input()
visited = set()
start = line.index('G')
stack = [start]
visited.add(start)
ok = False
while stack:
	current = stack.pop()
	left_option = current - jump
	right_option = current + jump
	if left_option < 0 or left_option >= len(line):
		pass
	if left_option in visited:
		pass
	if left_option >= 0 and line[left_option] == '.' and (left_option not in visited):
		visited.add(left_option)
		stack.append(left_option)
	if left_option >= 0 and line[left_option] == 'T':
		ok = True
		break
	if right_option < 0 or right_option >= len(line):
		continue
	if right_option in visited:
		pass
	if line[right_option] == '.' and right_option not in visited:
		visited.add(right_option)
		stack.append(right_option)
		continue
	if right_option >= 0 and line[right_option] == 'T':
		ok = True
		break
if ok:
	print('YES')
else:
	print('NO')


from collections import deque
found = False
(num_cells, jump_length) = tuple(map(int, input().strip().split()))
line = input().strip()
target = line.find('T')
visited = set()
queue = deque()
queue.appendleft(line)
while queue:
	line = queue.pop()
	visited.add(line)
	g_idx = line.find('G')
	if g_idx + jump_length == target or g_idx - jump_length == target:
		found = True
		break
	if g_idx + jump_length < len(line) and line[g_idx + jump_length] != '#':
		new_line = list(line)
		new_line[g_idx] = '.'
		new_line[g_idx + jump_length] = 'G'
		new_line = ''.join(new_line)
		if new_line not in visited:
			queue.appendleft(new_line)
	if g_idx - jump_length >= 0 and line[g_idx - jump_length] != '#':
		new_line = list(line)
		new_line[g_idx] = '.'
		new_line[g_idx - jump_length] = 'G'
		new_line = ''.join(new_line)
		if new_line not in visited:
			queue.appendleft(new_line)
if found:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = str(input())
g = s.index('G')
t = s.index('T')
b = 0
if g < t:
	while g <= t:
		if s[g] == 'G' or s[g] == '.':
			g += k
		elif s[g] == 'T':
			b = 1
			print('YES')
			break
		elif s[g] == '#':
			print('NO')
			b = 1
			break
		else:
			continue
	if b == 0:
		print('NO')
elif t == g:
	print('YES')
else:
	while g >= t:
		if s[g] == 'G' or s[g] == '.':
			g -= k
		elif s[g] == 'T':
			b = 1
			print('YES')
			break
		elif s[g] == '#':
			print('NO')
			b = 1
			break
		else:
			continue
	if b == 0:
		print('NO')


(line_size, steps) = map(int, input().split())
line = input()
grasshopper = line.index('G')
target = line.index('T')
(_from, _to) = (min(grasshopper, target), max(grasshopper, target))
jumps = [i for i in range(_from, _to + 1, steps)]
gap = abs(grasshopper - target)

def is_clear_line(jumps, line):
	return len([line[cell] for cell in jumps[1:-1] if line[cell] == '.']) == len(jumps[1:-1])
if gap % steps == 0 and is_clear_line(jumps, line):
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
ans = True
if s.find('G') > s.find('T'):
	s = s[::-1]
s = s[s.find('G')::k]
if s.find('T') != -1:
	s = s[:s.find('T') + 1]
	if '#' in s:
		ans = False
else:
	ans = False
if ans:
	print('YES')
else:
	print('NO')


a = list(map(int, input().split()))
b = input()
g = list(b).index('G')
t = list(b).index('T')
f = 1
if t < g:
	f = -1
i = 0
x = g
l = abs(t - g)
if l < a[1] or l % a[1] != 0:
	i = 1
l //= a[1]
while l != 0:
	if b[x] == '#':
		i = 1
		break
	x += f * a[1]
	l -= 1
if i == 0:
	print('YES')
if i == 1:
	print('NO')


def solution():
	number = input()
	seq = input()
	n = int(number.split()[0])
	k = int(number.split()[1])
	i = seq.find('T')
	j = seq.find('G')
	(i, j) = (min(i, j), max(i, j))
	while i + k <= j:
		i += k
		if seq[i] == '#':
			return False
		if seq[i] == 'T' or seq[i] == 'G':
			return True
	return False
if solution() == True:
	print('YES')
else:
	print('NO')


import sys, math
input = sys.stdin.readline

def inp():
	n = int(input())
	return n

def inlt():
	a = list(map(int, input().split()))
	return a

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	(a, b) = map(int, input().split())
	return (a, b)
t = 1
for i in range(t):
	(n, k) = invr()
	a = insr()
	if a.index('G') > a.index('T'):
		a.reverse()
	c = k
	j = a.index('G')
	while j < len(a):
		if j < n and a[j] == '#':
			print('NO')
			sys.exit()
		elif j < n and a[j] == 'T':
			print('YES')
			sys.exit()
		j = j + k
	print('NO')


(n, k) = map(int, input().split())
s = input()
pt = s.find('T')
pg = s.find('G')
if abs(pg - pt) % k != 0:
	print('NO')
else:
	if pg > pt:
		(pg, pt) = (pt, pg)
	flag = 1
	while pg != pt:
		if s[pg] == '#':
			flag = 0
			break
		pg += k
	if flag == 1:
		print('YES')
	else:
		print('NO')


(n, k) = [int(i) for i in input().split()]
s = input().split()[0]
g = s.find('G')
t = s.find('T')
mi = min(g, t)
ma = max(g, t)
ans = s[mi:ma + 1:k]
if (ma - mi) % k != 0:
	print('NO')
elif ans.find('#') > -1:
	print('NO')
else:
	print('YES')


(n, k) = [int(item) for item in input().split()]
s = list(input())
g = s.index('G')
t = s.index('T')
v = 0
if g < t:
	v = k
else:
	v = -k
i = g
while i >= 0 and i < n:
	if i == t:
		print('YES')
		break
	elif s[i] == '#':
		print('NO')
		break
	i += v
else:
	print('NO')


import sys
(a, b) = map(int, list(input().split()))
s = input()
for i in range(len(s)):
	if s[i] == 'G':
		l = i
	if s[i] == 'T':
		r = i
if l > r:
	(l, r) = (r, l)
if (r - l) % b != 0:
	print('NO')
	sys.exit()
for i in range(l, r, b):
	if s[i] == '#':
		print('NO')
		sys.exit()
print('YES')


def solve():
	k = int(input().split()[1])
	line = input()
	g = line.find('G')
	t = line.find('T')
	(g, t) = (min(g, t), max(g, t))
	if (t - g) % k:
		return 'NO'
	for i in range(g, t, k):
		if line[i] == '#':
			return 'NO'
	return 'YES'
print(solve())


def selection_sort(l):
	for i in range(len(l)):
		minimum_value = l[i]
		index_minimum = i
		for j in range(i, len(l)):
			if l[j] < minimum_value:
				minimum_value = l[j]
				index_minimum = j
		(l[i], l[index_minimum]) = (l[index_minimum], l[i])
	return l

def bubble_sort(l):
	for i in range(len(l)):
		for j in range(len(l) - i - 1):
			if l[j] > l[j + 1]:
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	return l

def insertion_sort(l):
	for i in range(len(l)):
		for j in range(i):
			k = i - j
			if l[k - 1] > l[k]:
				(l[k], l[k - 1]) = (l[k - 1], l[k])
			else:
				break
	return l

def merge_sort(l):

	def merge(l1, l2):
		(i, j) = (0, 0)
		output_list = []
		while i < len(l1) and j < len(l2):
			if l1[i] < l2[j]:
				output_list.append(l1[i])
				i += 1
			else:
				output_list.append(l2[j])
				j += 1
		if i == len(l1):
			output_list += l2[j:]
		else:
			output_list += l1[i:]
		return output_list

	def sort(l):
		if len(l) < 2:
			return l
		else:
			mid = len(l) // 2
			left = sort(l[:mid])
			right = sort(l[mid:])
			return merge(left, right)
	return sort(l)

def quick_sort(l):

	def partition(l, start, end):
		pivot_index = end
		i = start
		for j in range(start, end):
			if l[pivot_index] > l[j]:
				(l[j], l[i]) = (l[i], l[j])
				i += 1
		(l[i], l[pivot_index]) = (l[pivot_index], l[i])
		return i

	def recursive_part(l, start, end):
		if len(l) < 2:
			return l
		elif start < end:
			p = partition(l, start, end)
			recursive_part(l, start, p - 1)
			recursive_part(l, p + 1, end)
	return recursive_part(l, 0, len(l) - 1)

def main_function():
	(n, k) = [int(i) for i in input().split(' ')]
	s = list(input())
	is_g_found = False
	for i in range(len(s)):
		if s[i] == 'G':
			g = i
		elif s[i] == 'T':
			t = i
	if g > t:
		s.reverse()
	for i in range(len(s)):
		if is_g_found:
			new_indexing += 1
			if not new_indexing % k:
				if s[t + new_indexing] == '#':
					return 'No'
				elif s[t + new_indexing] == 'T':
					return 'Yes'
		elif s[i] == 'G':
			is_g_found = True
			new_indexing = 0
			t = i
	return 'No'
print(main_function())


(l, step) = [int(i) for i in input().split(' ')]
line = input()
gIndex = line.index('G')
tIndex = line.index('T')
found = False
if gIndex > tIndex:
	for i in range(gIndex, tIndex - 1, -step):
		if i == tIndex:
			print('YES')
			found = True
			break
		elif line[i] == '#':
			print('NO')
			found = True
			break
else:
	for i in range(gIndex, tIndex + 1, step):
		if i == tIndex:
			print('YES')
			found = True
			break
		elif line[i] == '#':
			found = True
			print('NO')
			break
if not found:
	print('NO')


(a, b) = map(int, input().split())
s = input()
a1 = 0
a2 = 0
for (i, c) in enumerate(s):
	if c == 'G':
		a1 = i
	if c == 'T':
		a2 = i
(a1, a2) = (min(a1, a2), max(a1, a2))
e = False
for i in range(a1, a2 + 1, b):
	if s[i] == '#':
		print('NO')
		exit()
	if i == a2:
		e = True
if e:
	print('YES')
else:
	print('NO')


import sys

def grasshopper_solve(r, w):
	data = r.readline().split()
	num_cells = int(data[0])
	hop_distance = int(data[1])
	path = list(r.readline())
	path.pop()
	hopper_index = 0
	target_index = 0
	for (i, val) in enumerate(path):
		if val == 'G':
			hopper_index = i
		elif val == 'T':
			target_index = i
	result = 'NO'
	queue = [hopper_index]
	visited = {}
	while len(queue) != 0:
		cur_index = queue.pop(0)
		if cur_index == target_index:
			result = 'YES'
			break
		if cur_index not in visited:
			visited[cur_index] = True
			left_dist = cur_index - hop_distance
			if left_dist >= 0 and path[left_dist] != '#':
				queue.append(left_dist)
			right_dist = cur_index + hop_distance
			if right_dist < num_cells and path[right_dist] != '#':
				queue.append(right_dist)
	w.write(result + '\n')
grasshopper_solve(sys.stdin, sys.stdout)


import sys
(n, k) = (int(i) for i in sys.stdin.readline().split())
seq = sys.stdin.readline().split()[0]
(G, T) = (0, 0)
for (i, char) in enumerate(seq):
	if char == 'G':
		G = i
	if char == 'T':
		T = i
start = min(G, T)
end = max(G, T)
flag = True
while start < end:
	if seq[start] == '#':
		print('NO')
		flag = False
		break
	start += k
if start == end:
	print('YES')
elif flag:
	print('NO')


(n, k) = map(int, input().split())
s = input()
l = len(s)
s = list(s)
(a, b) = (0, 0)
for i in range(l):
	if s[i] == 'T':
		a = i
	if s[i] == 'G':
		b = i
if a < b:
	(a, b) = (b, a)
if a - b < k or (a - b) % k != 0:
	print('NO')
	exit()
elif a - b == k:
	print('YES')
	exit()
for i in range(b, a, k):
	if s[i] == '#':
		print('NO')
		exit()
print('YES')


(n, k) = map(int, input().split())
s = input()
G = s.index('G')
T = s.index('T')

def check(u):
	if s[u] == 'T':
		exit(print('YES'))
	elif s[u] == '#':
		exit(print('NO'))
if G > T:
	u = G
	while u >= 0:
		check(u)
		u -= k
	print('NO')
else:
	u = G
	while u < len(s):
		check(u)
		u += k
	print('NO')


cases = input().split()
n = int(cases[0])
k = int(cases[1])
array = input()
t_index = 0
g_index = 0
for i in range(len(array)):
	if array[i] == 'T':
		t_index = i
	if array[i] == 'G':
		g_index = i
dis = abs(t_index - g_index)
rem = dis % k
counter = 0
if rem == 0:
	for j in range(min(t_index, g_index), max(t_index, g_index), k):
		if array[j] == '#':
			print('NO')
			counter += 1
			break
	if counter == 0:
		print('YES')
else:
	print('NO')


(N, K) = map(int, input().split())
S = input()
bad = set([])
for (i, s) in enumerate(S):
	if s == '#':
		bad.add(i + 1)
	elif s == 'G':
		start = i + 1
	elif s == 'T':
		end = i + 1
if start < end:
	while start < end:
		start += K
		if start in bad:
			print('NO')
			exit()
	if start == end:
		print('YES')
		exit()
	else:
		print('NO')
		exit()
while start > end:
	start -= K
	if start in bad:
		print('NO')
		exit()
if start == end:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = str(input())
i = s.find('G')
j = s.find('T')
if i < j:
	if (j - i) % k == 0:
		while i != j:
			if s[i] == '#':
				print('NO')
				exit()
			i += k
		print('YES')
	else:
		print('NO')
elif (i - j) % k == 0:
	while i != j:
		if s[i] == '#':
			print('NO')
			exit()
		i -= k
	print('YES')
else:
	print('NO')


(n, k) = [int(x) for x in input().split()]
box = list(input())
jump = []
pos = 0
target = 0
ob = []
for i in range(n):
	if box[i] == 'G':
		jump.append(1)
		pos = i
	elif box[i] == 'T':
		target = i
		jump.append(2)
	elif box[i] == '#':
		ob.append(i)
		jump.append(3)
	else:
		jump.append(0)
if pos < target:
	for i in range(pos, target):
		if jump[i] == 3:
			if abs(i - pos) % k == 0:
				print('NO')
				exit()
else:
	for i in range(pos, target, -1):
		if jump[i] == 3:
			if abs(i - pos) % k == 0:
				print('NO')
				exit()
if abs(target - pos) % k == 0:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = [i for i in input()]
gen_path_to_right = []
gen_path_to_left = []
i = a.index('G')
j = i
while True:
	if j >= n or a[j] == '#':
		break
	gen_path_to_right.append(j)
	j += k
j = i
while True:
	if j < 0 or a[j] == '#':
		break
	gen_path_to_left.append(j)
	j -= k
t = a.index('T')
if t in gen_path_to_left or t in gen_path_to_right:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
a = s.index('G')
b = s.index('T')
(a, b) = (min(a, b), max(a, b))
if (b - a) % k != 0:
	print('NO')
	exit()
for i in range(a, b + 1, k):
	if s[i] == '#':
		print('NO')
		exit()
print('YES')


import sys
(n, k) = map(int, input().split())
str = input()
start = str.index('G')
target = str.index('T')
if target < start:
	(start, target) = (target, start)
diff = target - start
if diff < k:
	print('NO')
	sys.exit(0)
cnt = k
not_found = True
while start <= target:
	np = start
	if str[np] == '#':
		print('NO')
		not_found = False
		break
	elif start == target:
		print('YES')
		not_found = False
		break
	else:
		start += k
if not_found:
	print('NO')


(n, k) = [int(s) for s in input().split(' ')]
s = input()
g = s.index('G')
t = s.index('T')
if (g - t) % k == 0 and '#' not in s[min(g, t):max(g, t) + 1:k]:
	print('YES')
else:
	print('NO')


inp = input()
board = input()
inp = inp.strip('\n')
inp = inp.split()
spaces = int(inp[0])
jlen = int(inp[1])
g = 0
t = 0
pd = []
dt = []
val = {}

def search(a):
	val[a] = False
	if a == t:
		return True
	if val[a + jlen] == True and t > g:
		return search(a + jlen)
	if val[a - jlen] == True and t < g:
		return search(a - jlen)
	elif val[a + jlen] == False and val[a - jlen] == False:
		return False
	return False
for i in range(0 - jlen - 3, spaces + jlen + 3):
	if i < 0 or i > spaces - 1:
		val[i] = False
	elif board[i] == 'G':
		g = i
		val[i] = True
	elif board[i] == 'T':
		t = i
		val[i] = True
	elif board[i] == '#':
		pd.append(i)
		val[i] = False
	elif board[i] == '.':
		dt.append(i)
		val[i] = True
if search(g) == True:
	print('YES')
else:
	print('NO')


(l, k) = [int(i) for i in input().strip().split()]
arena = input().strip()
starting_pos = arena.index('G')
for i in range(arena.index('G'), len(arena), k):
	if arena[i] == '#':
		break
	elif arena[i] == '.' or arena[i] == 'G':
		continue
	else:
		print('YES')
		exit(0)
for i in range(starting_pos, -1, -k):
	if arena[i] == '#':
		break
	elif arena[i] == '.' or arena[i] == 'G':
		continue
	else:
		print('YES')
		exit(0)
print('NO')


l = [int(i) for i in input().split()]
s = str(input())
n = l[0]
k = l[1]
i = 0
while i < n:
	if s[i] == 'G':
		break
	i += 1
r = False
for j in range(i, n, k):
	if 'T' == s[j]:
		r = True
		break
	if '#' == s[j]:
		break
for j in range(i, -1, -k):
	if 'T' == s[j]:
		r = True
		break
	if '#' == s[j]:
		break
if r:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = list(input())
g = s.index('G')
t = s.index('T')
start = min(g, t)
end = max(g, t)
if (end - start) % k == 0:
	index = start
	blocked = 0
	while index < end:
		if s[index] == '#':
			blocked = 1
		index += k
	if not blocked:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def main():
	(n, k) = map(int, input('').strip().split(' '))
	cells = input('').strip()
	start = next((i for (i, x) in enumerate(cells) if x == 'G'))
	end = next((i for (i, x) in enumerate(cells) if x == 'T'))
	seen = {}
	queue = [start]
	while queue:
		node = queue.pop()
		if node == end:
			print('YES')
			return
		right = node + k
		if right >= len(cells):
			right = None
		left = node - k
		if left < 0:
			left = None
		if left is not None and left not in seen and (cells[left] != '#'):
			queue.append(left)
		if right is not None and right not in seen and (cells[right] != '#'):
			queue.append(right)
		seen[node] = True
	print('NO')
main()


(n, k) = map(int, input().split())
s = str(input())
G = s.index('G')
T = s.index('T')
if abs(G - T) % k != 0:
	print('NO')
else:
	i = G
	ok = 1
	while 1:
		i += k * (T > G) - k * (G > T)
		if i >= n:
			break
		if i < 0:
			break
		if s[i] == '#':
			print('NO')
			ok = 0
			break
		if s[i] == 'T':
			break
	if ok == 1:
		print('YES')


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(n, k) = (int(i) for i in input().split())
s = list(input())
k1 = s.index('G')
k2 = s.index('T')
if k1 > k2:
	c1 = 1
	c2 = 0
	for i in range(k1, k2 - 1, -k):
		if i == k2:
			c2 = 1
			break
		if s[i] == '#':
			c1 = 0
			break
else:
	c1 = 1
	c2 = 0
	for i in range(k1, k2 + 1, k):
		if i == k2:
			c2 = 1
			break
		if s[i] == '#':
			c1 = 0
			break
if c1 == 1 and c2 == 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
l = [s.index('G'), s.index('T')]
start = min(l)
stop = max(l)
f = True
for i in range(start, stop + 1, k):
	if s[i] == '#':
		f = False
		break
f = f and (stop - start) % k == 0
print('Yes' if f else 'No')


import sys
from collections import deque
inputs = sys.stdin.read().split('\n')
paras = inputs[0].split(' ')
(numCells, hopDist) = (int(paras[0]), int(paras[1]))
line = inputs[1]
startPos = 0
goalPos = 0
for (idx, cell) in enumerate(line):
	if cell == 'G':
		startPos = idx
	elif cell == 'T':
		goalPos = idx
if abs(goalPos - startPos) % hopDist != 0:
	print('NO')
	exit()
currPos = startPos
while True:
	currPos += hopDist if goalPos > startPos else -hopDist
	if line[currPos] == '#':
		print('NO')
		exit()
	elif line[currPos] == 'T':
		print('YES')
		exit()


(n, k) = map(int, input().split())
line = input()
steps = []
(posg, post) = (line.index('G'), line.index('T'))
dist = abs(line.index('G') - line.index('T'))
if dist % k != 0:
	print('NO')
	exit()
while posg != post:
	if post > posg:
		posg += k
	else:
		posg -= k
	steps.append(line[posg])
if '#' in steps:
	print('NO')
else:
	print('YES')


import sys
(n, k) = [int(x) for x in input().split()]
s = input()
if s.find('G') > s.find('T'):
	s = s[::-1]
for i in s[s.find('G'):s.find('T') + 1:k]:
	if i == 'T':
		print('YES')
		sys.exit(0)
	elif i == '#':
		break
print('NO')


from math import *
from sys import *
from queue import *
from decimal import *
(n, k) = (int(z) for z in input().split())
s = input()
i = 0
while i < len(s) and s[i] not in ['G', 'T']:
	i += 1
i += k
while i < len(s) and s[i] not in ['G', 'T', '#']:
	i += k
if i >= len(s) or s[i] == '#':
	print('NO')
else:
	print('YES')


(n, k) = [int(x) for x in input().split()]
d = [False] * n
t = input()
tmp = t.index('G')
i = tmp + k
can = True
ans = False
while i < n and can:
	if t[i] == '#':
		can = False
	else:
		d[i] = True
		i += k
i = tmp - k
can = True
while i > -1 and can:
	if t[i] == '#':
		can = False
	else:
		d[i] = True
		i -= k
td = t.index('T')
if d[td] == True:
	print('YES')
else:
	print('NO')


def rints():
	return list(map(int, input().split()))

def ri():
	return int(input())
(n, k) = rints()
s = input()

def solve():
	for i in range(n):
		if s[i] in 'GT':
			start = i
			break
	for j in range(start + k, n, k):
		if s[j] in 'GT':
			return 'YES'
		if s[j] == '#':
			return 'NO'
	return 'NO'

def main():
	print(solve())
main()


(_, k) = [int(x) for x in input().split()]
trace = input()
gi = trace.index('G')
ti = trace.index('T')
if abs(gi - ti) % k == 0:
	if not '#' in trace[min(gi, ti):max(gi, ti):k]:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
g = -1
t = -1
for i in range(n):
	if s[i] == 'G':
		g = i
	if s[i] == 'T':
		t = i
st = g
while True:
	st += k
	if st >= n or s[st] == '#':
		break
	if st == t:
		print('YES')
		exit()
while True:
	st -= k
	if st < 0 or s[st] == '#':
		break
	if st == t:
		print('YES')
		exit()
print('NO')


NandK = input().split()
(n, k) = [int(i) for i in NandK]
line = input()
gIndex = line.index('G')
tIndex = line.index('T')
stepsAway = tIndex - gIndex
if stepsAway % k != 0:
	print('NO')
	exit()
currPos = gIndex
if stepsAway < 0:
	k = -1 * k
while True:
	currPos += k
	if line[currPos] == '#':
		print('NO')
		exit()
	elif line[currPos] == 'T':
		print('YES')
		exit()


(n, k) = map(int, input().split(' '))
s = input()
(g, h) = (s.find('G'), s.find('T'))
(g, h) = (min(g, h), max(g, h))
if (h - g) % k != 0 or any([c == '#' for c in s[g:h:k]]):
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input().strip('#')
x = s.index('G')
y = s.index('T')
a = abs(x - y)
flag = 0
if y < x:
	s = s[::-1]
	temp = x
	x = y
	y = temp
	x = s.index('G')
	y = s.index('T')
if a % k == 0:
	if '#' in s:
		while x < y:
			if s[x + k] == '#':
				print('NO')
				flag = 1
				break
			x = x + k
		if flag == 0:
			print('YES')
	else:
		print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = input()
cnt = 0
d = 0
g = c[::b]
cnt = c.find('G')
d = c.find('T')
if cnt > d:
	(cnt, d) = (d, cnt)
if (cnt - d) % b != 0:
	print('NO')
else:
	for i in range(cnt, d, b):
		if c[i] == '#':
			print('NO')
			exit()
	print('YES')


(n, k) = input().split()
(n, k) = [int(n), int(k)]
s = str(input())
a = s.index('G')
b = s.index('T')
check = False
if a > b:
	s = s[::-1]
	a = s.index('G')
for i in range(a, n, k):
	if s[i] == '#':
		print('NO')
		check = True
		break
	elif s[i] == '.':
		pass
	elif s[i] == 'T':
		print('YES')
		check = True
		break
if check == False:
	print('NO')


import sys
f_line = sys.stdin.readline()
f_input = f_line.split()
cell_size = int(f_input[0])
jump_size = int(f_input[1])
s_line = sys.stdin.readline()
s_input = list(s_line)
eaten = False
curr_index = 0
animal_received = 0
while eaten == False and curr_index < cell_size:
	if s_input[curr_index] == 'G' or s_input[curr_index] == 'T':
		if animal_received == 0:
			animal_received = 1
			curr_index = curr_index + jump_size
		elif animal_received == 1:
			eaten = True
	elif animal_received == 1:
		if s_input[curr_index] == '.':
			curr_index = curr_index + jump_size
		else:
			curr_index = curr_index + cell_size + 2
	else:
		curr_index = curr_index + 1
if eaten == False:
	print('NO')
else:
	print('YES')


(n, j) = map(int, input().split())
l = input()
a = l.index('G')
b = l.index('T')
if b > a:
	a = a + j
	while True:
		if a > n - 1:
			print('NO')
			break
		elif l[a] == '#':
			print('NO')
			break
		elif l[a] == 'T':
			print('YES')
			break
		a = a + j
elif b < a:
	a = a - j
	while True:
		if a < 0:
			print('NO')
			break
		elif l[a] == '#':
			print('NO')
			break
		elif l[a] == 'T':
			print('YES')
			break
		a = a - j


temp = input().split(' ')
n = int(temp[0])
k = int(temp[1])
s = input()
g = s.find('G')
t = s.find('T')
temp = 0
if g < t:
	while t >= g and g < n:
		if g == t:
			print('YES')
			temp = 1
			break
		elif s[g] == '#':
			print('NO')
			temp = 1
			break
		g += k
	if temp == 0:
		print('NO')
else:
	while t <= g and g < n:
		if g == t:
			print('YES')
			temp = 1
			break
		elif s[g] == '#':
			print('NO')
			temp = 1
			break
		g -= k
	if temp == 0:
		print('NO')


def hop(nums: int, jump: int, cells: str):
	g_index = cells.find('G')
	t_index = cells.find('T')
	dir = 1
	if t_index < g_index:
		dir = -1
	cur = int(g_index)
	while cur >= 0 and cur < nums:
		if cells[cur] == 'T':
			return 'YES'
		elif cells[cur] == '#':
			break
		cur += jump * dir
		if cur < 0 or cur >= nums:
			break
	return 'NO'

def main():
	(nums, jump) = input().split()
	cells = input()
	print(hop(int(nums), int(jump), cells))
main()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
(n, k) = get_int_list()
s = get_string()
if s.index('G') < s.index('T'):
	i = s.index('G')
	flag = False
	while i + k < n:
		i += k
		if s[i] == 'T':
			flag = True
			break
		if s[i] == '#':
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')
else:
	i = s.index('G')
	flag = False
	while i - k >= 0:
		i -= k
		if s[i] == 'T':
			flag = True
			break
		if s[i] == '#':
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def grass(string, k):
	g = string.index('G')
	t = string.index('T')
	if g < t:
		i = g
		i = i + k
		while i < t + 1:
			if string[i] == '#':
				return 'No'
			if string[i] == 'T':
				return 'Yes'
			i = i + k
	elif g > t:
		i = g
		i = i - k
		while i >= t - 1:
			if string[i] == '#':
				return 'No'
			if string[i] == 'T':
				return 'Yes'
			i = i - k
	return 'No'
(n, k) = map(int, input().split())
string = input()
print(grass(string, k))


def path_for_kuznechik(n, k, way):
	G_num = way.find('G')
	T_num = way.find('T')
	if T_num < G_num:
		k = -k
	i = G_num
	if abs(G_num - T_num) % abs(k) != 0:
		print('NO')
	else:
		while True:
			if way[i + k] == '.':
				i += k
			elif way[i + k] == 'T':
				print('YES')
				break
			else:
				print('NO')
				break
(n, k) = [int(k) for k in input().strip().split(' ')]
way = [k for k in input().strip().split(' ')][0]
path_for_kuznechik(n, k, way)


from math import *

def main():
	(n, k) = list(map(int, input().split()))
	s = input()
	G_pos = -1
	T_pos = -1
	obstacle = set()
	for (i, x) in enumerate(s):
		if x == 'G':
			G_pos = i
		elif x == 'T':
			T_pos = i
		elif x == '#':
			obstacle.add(i)
	if G_pos > T_pos:
		(G_pos, T_pos) = (T_pos, G_pos)
	if (G_pos - T_pos) % k != 0:
		return 'NO'
	if not any((j in obstacle for j in range(G_pos, T_pos, k))):
		return 'YES'
	else:
		return 'NO'
print(main())


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def power_set(L):
	cardinality = len(L)
	n = 2 ** cardinality
	powerset = []
	for i in range(n):
		a = bin(i)[2:]
		subset = []
		for j in range(len(a)):
			if a[-j - 1] == '1':
				subset.append(L[j])
		powerset.append(subset)
	powerset_orderred = []
	for k in range(cardinality + 1):
		for w in powerset:
			if len(w) == k:
				powerset_orderred.append(w)
	return powerset_orderred

def fastPlrintNextLines(a):
	print('\n'.join(map(str, a)))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = 1
for _ in range(t):
	(n, k) = li()
	s = list(si())
	i = s.index('G')
	j = s.index('T')
	flag = 0
	r = 0
	l = 0
	if i < j:
		r = 1
	else:
		l = 1
	while i != j:
		if r == 1:
			i += k
			if i == j:
				break
			else:
				if i >= len(s):
					flag = 1
					break
				if s[i] == '#':
					flag = 1
					break
		else:
			i -= k
			if i == j:
				break
			else:
				if i < 0:
					flag = 1
					break
				if s[i] == '#':
					flag = 1
					break
	if flag == 0:
		print('YES')
	else:
		print('NO')


(n, k) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
if g > t:
	(g, t) = (t, g)
if (t - g) % k == 0:
	for i in range(g, t, k):
		if s[i] == '#':
			print('NO')
			exit(0)
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
x = list(input())
G = x.index('G')
T = x.index('T')
f = 'YES'
for i in range(min(G, T), max(G, T) + 1):
	if x[i] == '#' and abs(i - G) % b == 0:
		f = 'NO'
	elif x[i] == 'T' and abs(G - T) % b != 0:
		f = 'NO'
print(f)


from queue import deque

def runProgram():
	params = [int(i) for i in input().split()]
	line = list(input())
	startInd = line.index('G')
	length = len(line)
	visitedArr = [False for i in range(length)]
	visitedArr[startInd] = True
	q = deque()
	q.append(startInd)
	while q:
		index = q.popleft() + params[1]
		if index < length and (not line[index] == '#') and (not visitedArr[index]):
			if line[index] == 'T':
				return 'YES'
			visitedArr[index] = True
			q.append(index)
		index -= 2 * params[1]
		if index >= 0 and (not line[index] == '#') and (not visitedArr[index]):
			if line[index] == 'T':
				return 'YES'
			visitedArr[index] = True
			q.append(index)
	return 'NO'
print(runProgram())


(n, k) = map(int, input().split())
cells = list(input())
g = cells.index('G')
res = 'NO'
r = g
while r < n and cells[r] != '#':
	if cells[r] == 'T':
		res = 'YES'
		break
	r += k
r = g if res == 'NO' else -1
while r >= 0 and cells[r] != '#':
	if cells[r] == 'T':
		res = 'YES'
		break
	r -= k
print(res)


(n, k) = list(map(int, input().split()))
t = input()
b = t.index('G')
a = t.index('T')
if abs(b - a) % k != 0:
	print('NO')
else:
	h = 0
	if b > a:
		for i in range(a, b, k):
			if t[i] == '#':
				print('NO')
				h += 1
				break
		if h == 0:
			print('YES')
	else:
		for j in range(b, a, k):
			if t[j] == '#':
				print('NO')
				h += 1
				break
		if h == 0:
			print('YES')


import sys
a = input().split()
length = int(a[0])
hops = int(a[1])
b = list(input())
flag = False
start = 0
for k in range(0, length):
	if b[k] == 'G':
		start = k
		break
for i in range(start, length, hops):
	if b[i] == '#':
		break
	elif b[i] == 'T':
		print('YES')
		sys.exit()
for j in range(start, -1, hops * -1):
	if b[j] == '#':
		break
	elif b[j] == 'T':
		print('YES')
		sys.exit()
print('NO')


(n, k) = map(int, input().split())
l = list(input())
m = min(l.index('G'), l.index('T'))
d = abs(l.index('G') - l.index('T'))
if d % k == 0:
	for i in range(m, m + d, k):
		if l[i] == '#':
			print('NO')
			break
	else:
		print('YES')
else:
	print('NO')


(n, k) = [int(i) for i in input().split()]
obstacles = set()
s = input()
kr = []
for i in range(n):
	if s[i] in ['G', 'T']:
		kr.append(i)
	elif s[i] == '#':
		obstacles.add(i)
(a, b) = kr
if (b - a) % k == 0:
	broken = False
	for i in range(a, b, k):
		if i in obstacles:
			print('NO')
			broken = True
			break
	if not broken:
		print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
(s, g) = (input(), 0)
for i in range(n):
	if s[i] == 'G' or s[i] == 'T':
		g = i
		break
for i in range(g + k, n, k):
	if s[i] == 'G' or s[i] == 'T':
		exit(print('YES'))
	if s[i] == '#':
		break
print('NO')


n_k = input().split(' ')
n = int(n_k[0])
k = int(n_k[1])
line = list(input())
start = line.index('G')
dest = line.index('T')
reached = False
if start > dest:
	cur = start
	while cur >= 0 and (not reached):
		if line[cur] == '#':
			break
		if cur == dest:
			reached = True
		cur -= k
else:
	cur = start
	while cur < len(line) and (not reached):
		if line[cur] == '#':
			break
		if cur == dest:
			reached = True
		cur += k
if reached:
	print('YES')
else:
	print('NO')


import sys
(n, j) = [int(a_temp) for a_temp in input().strip().split()]
line = input().strip()
t = g = -1
for (i, c) in enumerate(line):
	if c == 'T':
		t = i
	elif c == 'G':
		g = i
distance = abs(t - g)
if j > n or distance % j != 0:
	print('NO')
else:
	if t < g:
		(t, g) = (g, t)
	while t != g:
		g += j
		if line[g] == '#':
			print('NO')
			sys.exit()
	print('YES')


(n, k) = map(int, input().split())
s = input()
if abs(s.find('G') - s.find('T')) % k == 0:
	for i in range(min(s.find('G'), s.find('T')), max(s.find('G'), s.find('T')), k):
		if s[i] == '#':
			print('NO')
			exit()
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
T_index = None
G_index = None
l = 0
string = input()
for i in string:
	if i == 'T' or i == 'G':
		break
	l += 1
for i in range(l + k, n, k):
	if string[i] == 'T' or string[i] == 'G':
		print('YES')
		break
	elif string[i] == '#':
		print('NO')
		break
else:
	print('NO')


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	(n, k) = read_ints()
	s = input()
	a = s.index('G')
	b = s.index('T')
	if a > b:
		(a, b) = (b, a)
	if (b - a) % k != 0:
		NO()
		return
	for i in range(a, b, k):
		if s[i] == '#':
			NO()
			return
	YES()

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


from math import ceil
(n, k) = map(int, input().split())
l = input()
G = l.index('G')
T = l.index('T')
k1 = 0
if G < T:
	r = (T - G) / k
	if r < ceil(r) or r == 0:
		print('NO')
	else:
		for i in range(T, G - 1, -k):
			if l[i] == '#':
				k1 = 1
				print('NO')
				break
			else:
				continue
		if k1 == 0:
			print('YES')
elif T < G:
	r = (G - T) / k
	if r < ceil(r) or r == 0:
		print('NO')
	else:
		for i in range(G, T - 1, -k):
			if l[i] == '#':
				k1 = 1
				print('NO')
				break
			else:
				continue
		if k1 == 0:
			print('YES')


(n, k) = list(map(int, input().split()))
s = input()
x = s.find('G')
ans = False
for i in range(x, n, k):
	if s[i] == '#':
		ans = False
		break
	if s[i] == 'T':
		ans = True
		break
if ans == True:
	print('YES')
else:
	for i in range(x, -1, -k):
		if s[i] == '#':
			ans = False
			break
		if s[i] == 'T':
			ans = True
			break
	if ans == True:
		print('YES')
	else:
		print('NO')


(n, k) = (int(x) for x in input().split())
st = input()
start = st.find('G')
finish = st.find('T')
found = False
if start < finish:
	pos = start
	while pos < len(st):
		if st[pos] == 'T':
			found = True
			break
		elif st[pos] == '#' or pos > finish:
			break
		else:
			pos += k
else:
	pos = start
	while pos >= 0:
		if st[pos] == 'T':
			found = True
			break
		elif st[pos] == '#' or pos < finish:
			break
		else:
			pos -= k
if found == True:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
pos = -1
pos1 = -1
for i in range(len(s)):
	if s[i] == 'G':
		pos = i
	if s[i] == 'T':
		pos1 = i
if pos % k != pos1 % k:
	print('NO')
	exit(0)
if pos < pos1:
	while pos < len(s):
		if s[pos] == '#':
			print('NO')
			exit(0)
		if pos == pos1:
			print('YES')
			exit(0)
		pos += k
	print('NO')
	exit(0)
if pos > pos1:
	while pos >= 0:
		if s[pos] == '#':
			print('NO')
			exit(0)
		if pos == pos1:
			print('YES')
			exit(0)
		pos -= k
	print('NO')
	exit(0)


(n, k) = map(int, input().split())
st = input()
g_pos = st.find('G')
t_pos = st.find('T')
diff = abs(t_pos - g_pos)
if diff % k == 0:
	if t_pos > g_pos:
		pos = g_pos + k
		while st[pos] != 'T' and st[pos] != '#':
			g_pos = pos
			pos = g_pos + k
		if st[pos] == '#':
			print('NO')
		else:
			print('YES')
	else:
		pos = g_pos - k
		while st[pos] != 'T' and st[pos] != '#':
			g_pos = pos
			pos = g_pos - k
		if st[pos] == '#':
			print('NO')
		else:
			print('YES')
else:
	print('NO')


nk = [int(x) for x in input().split()]
k = int(nk[1])
val = input()
(g, t) = (0, 0)
for x in range(len(val)):
	if val[x] == 'G':
		g = x
	elif val[x] == 'T':
		t = x
if abs(g - t) % k != 0:
	print('NO')
elif g > t:
	temp = g - k
	while True:
		if temp > t:
			if val[temp] == '#':
				break
		else:
			break
		temp = temp - k
	if temp == t:
		print('YES')
	else:
		print('NO')
else:
	temp = g + k
	while True:
		if temp < t:
			if val[temp] == '#':
				break
		else:
			break
		temp = temp + k
	if temp == t:
		print('YES')
	else:
		print('NO')


(n, k) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
dis = g - t
if abs(dis) % k == 0 and dis < 0:
	for i in range(g, t + 1, k):
		if s[i] == '#':
			print('NO')
			exit()
elif dis % k == 0 and dis >= 0:
	for i in range(t, g + 1, k):
		if s[i] == '#':
			print('NO')
			exit()
else:
	print('NO')
	exit()
print('YES')


(n, k) = map(int, input().split())
s = input()
(g, t) = (s.index('G'), s.index('T'))
print('NO' if (g - t) % k or sum([s[i] == '#' for i in range(g, t, -k * (g - t) // abs(g - t))]) else 'YES')


(n, k) = list(map(int, input().split()))
s = input()
start = s.index('G')
for i in range(start, len(s), k):
	if s[i] == '#':
		break
	elif s[i] == 'T':
		print('YES')
		exit()
for i in range(start, -1, -k):
	if s[i] == '#':
		break
	elif s[i] == 'T':
		print('YES')
		exit()
print('NO')


(n, k) = input().split()
n = int(n)
k = int(k)
chars = []
st = 0
tgt = 0
chars = input()
for i in range(0, n):
	if chars[i] == 'G':
		st = i
	if chars[i] == 'T':
		tgt = i
flag = 0
if st < tgt:
	if not (tgt - st) % k == 0:
		flag = 1
	else:
		for i in range(st, tgt + 1, k):
			if chars[i] == '#':
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')
else:
	if not (st - tgt) % k == 0:
		flag = 1
	else:
		for i in range(tgt, st + 1, k):
			if chars[i] == '#':
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
(n, k) = map(int, sys.stdin.readline().split())
line = input()
g = line.find('G')
t = line.find('T')
beg = min(g, t)
end = max(g, t)
ans = True
if (beg - end) % k != 0:
	ans = False
for i in range(beg, end, k):
	if line[i] == '#':
		ans = False
		break
if ans:
	print('YES')
else:
	print('NO')


import sys
(n, k) = map(int, input().split())
string = input()
gpos = string.index('G')
tpos = string.index('T')
no = 0
if gpos < tpos:
	while gpos != tpos:
		gpos += k
		if gpos >= n or gpos > tpos or string[gpos] == '#':
			no = 1
			break
else:
	while gpos != tpos:
		gpos -= k
		if gpos < 0 or gpos < tpos or string[gpos] == '#':
			no = 1
			break
if no == 0:
	print('YES')
else:
	print('NO')


import os
LOCAL_PC = 'n1amr' in os.path.expanduser('~')

def solve(input, print):
	(n, k) = map(int, input().split())
	s = list(input())
	print('YES' if ans(n, k, s) else 'NO')

def ans(n, k, s):
	g = s.index('G')
	t = s.index('T')
	if g > t:
		s = list(reversed(s))
		g = s.index('G')
		t = s.index('T')
	while True:
		if g + k == t:
			return True
		elif g + k > t or s[g + k] == '#':
			return False
		g += k

def process_file(in_name, out_name):
	with open(in_name, 'r') as fin:
		with open(out_name, 'w') as fout:

			def read():
				return fin.readline().rstrip('\n')

			def write(*args, end='\n'):
				text = ' '.join(map(str, args)) + end
				fout.write(text)
				print(text, end='')
			t = int(fin.readline())
			for i in range(t):
				read()
				write('Case #{T}: \n'.format(T=i + 1), end='')
				solve(read, write)
				write()

def process_stdio():

	def read():
		return input()

	def write(*args, end='\n'):
		print(*args, end=end)
	solve(read, write)
if LOCAL_PC:
	in_name = __file__[:-3] + '.in'
	out_name = __file__[:-3] + '.out'
	process_file(in_name, out_name)
else:
	process_stdio()


(n, k) = [int(x) for x in input().split()]
s = input()
sg = s.find('G')
st = s.find('T')
if sg > st:
	k *= -1
while True:
	sg += k
	if sg == st:
		print('YES')
		exit()
	elif sg > n - 1 or sg < 0:
		print('NO')
		exit()
	elif s[sg] == '#':
		print('NO')
		exit()


n = list(map(int, input().rstrip().split()))
path = input()
skip = n[1]
Gind = path.index('G')
Gind += skip
found = 0
while Gind < len(path):
	if path[Gind] == '#':
		break
	if path[Gind] == 'T':
		found = 1
		break
	Gind += skip
Gind = path.index('G')
while Gind >= 0:
	if path[Gind] == '#':
		break
	if path[Gind] == 'T':
		found = 1
		break
	Gind -= skip
if found == 1:
	print('YES')
else:
	print('NO')


from math import ceil
Input = lambda : map(int, input().split())

def cal(s, G, T, k):
	for i in range(G, T + 1, k):
		if s[i] == '#':
			return False
	return True
(n, k) = Input()
s = input()
G = s.index('G')
T = s.index('T')
if G > T:
	(G, T) = (T, G)
i = (T - G) / k
if ceil(i) - i != 0:
	print('NO')
	exit()
print('YES' if cal(s, G, T, k) else 'NO')


(n, k) = map(int, input().split())
data = input()
start = -1
result = ''
for (i, c) in enumerate(data):
	if start == -1 and c in 'GT':
		start = i
	elif start != -1 and (i - start) % k == 0:
		if c in 'GT':
			result = 'YES'
			break
		elif c == '#':
			result = 'NO'
			break
print(result or 'NO')


def main():
	(n, k) = list(map(int, input().split()))
	s = input()
	for (i, c) in enumerate(s):
		if c == 'G':
			g = i
		if c == 'T':
			t = i
	if t < g:
		(t, g) = (g, t)
	if (t - g) % k != 0:
		print('NO')
		return
	for i in range(g, t, k):
		if s[i] == '#':
			print('NO')
			return
	print('YES')
main()


def gg(v):
	if v == sp:
		print('YES')
		exit(0)
	if v < 0 or v >= n or used[v] or (s[v] == '#'):
		return
	used[v] = True
	gg(v + k)
	gg(v - k)
(n, k) = map(int, input().split())
s = input()
used = [False] * n
(st, sp) = (0, 0)
for i in range(n):
	if s[i] == 'G':
		st = i
	if s[i] == 'T':
		sp = i
gg(st)
print('NO')


import sys
line = list(map(int, sys.stdin.readline().split()))
k = line[1]
length = line[0]
line = sys.stdin.readline()[:-1]
grasshopper = 0
target = 0
for i in range(len(line)):
	if line[i] == 'G':
		grasshopper = i
	elif line[i] == 'T':
		target = i
if grasshopper > target:
	k *= -1
reachable = True
if (grasshopper - target) % k != 0:
	reachable = False
for i in range(grasshopper, target, k):
	if line[i] == '#':
		reachable = False
if reachable:
	print('YES')
else:
	print('NO')


def posLeft(curPos, lt, num):
	global check
	if curPos == finishPos:
		check = True
		return 0
	elif curPos < 0:
		return 0
	elif lt[curPos] == '#':
		return 0
	elif curPos != finishPos:
		posLeft(curPos - k, lt, num + 1)

def posRight(curPos, lt, num):
	global check
	if curPos == finishPos:
		check = True
	elif curPos > len(lt) - 1:
		return 0
	elif lt[curPos] == '#':
		return 0
	elif curPos != finishPos:
		posRight(curPos + k, lt, num + 1)
(n, k) = list(map(int, input().split()))
lt = list(input())
check = False
i1 = 0
for i in lt:
	if i == 'G':
		startPos = i1
	if i == 'T':
		finishPos = i1
	i1 += 1
posLeft(startPos, lt, 1)
posRight(startPos, lt, 1)
if check:
	print('YES')
else:
	print('NO')


(n, k) = input().split()
(n, k) = (int(n), int(k))
s = str(input())
a = abs(s.index('G') - s.index('T'))
if a % k == 0:
	c = 0
	for i in range(min(s.index('G'), s.index('T')), max(s.index('G'), s.index('T')), k):
		if s[i] == '#':
			c += 1
			print('NO')
			break
	if c == 0:
		print('YES')
else:
	print('NO')


import sys
from collections import Counter
from math import factorial
input = sys.stdin
output = sys.stdout

def read_int():
	return [int(x) for x in input.readline().rstrip().split()]
(n, k) = read_int()
line = input.readline().rstrip()
answer = 'NO'
for g in range(n):
	if line[g] == 'G':
		for i in range(g, n, k):
			if line[i] == '#':
				break
			if line[i] == 'T':
				answer = 'YES'
				break
		for i in range(g, -1, -k):
			if line[i] == '#':
				break
			if line[i] == 'T':
				answer = 'YES'
				break
output.write('%s\n' % answer)


def Gr(s, g, t, k):
	for i in range(g, t + 1, k):
		if s[i] == 'T':
			return 'YES'
		if s[i] == '#':
			return 'NO'
	return 'NO'
(n, k) = list(map(int, input().split()))
s = input()
for i in range(n):
	if s[i] == 'G':
		g = i
	if s[i] == 'T':
		t = i
print(Gr(s, g, t, k) if g < t else Gr(s, g, t - 2, -k))


rawinput = list(map(int, input().split()))
stringLength = rawinput[0]
jumpLength = rawinput[1]
done = False
stringInput = input()
gPos = stringInput.find('G')
tPos = stringInput.find('T')
if gPos < tPos:
	forward = True
else:
	forward = False
if abs(gPos - tPos) < jumpLength:
	print('NO')
	exit()
while done == False:
	if forward:
		if gPos + jumpLength >= stringLength:
			print('NO')
			done = True
		elif stringInput[gPos + jumpLength] == 'T':
			print('YES')
			done = True
		elif stringInput[gPos + jumpLength] == '#':
			print('NO')
			done = True
		else:
			gPos = gPos + jumpLength
	elif gPos - jumpLength < 0:
		print('NO')
		done = True
	elif stringInput[gPos - jumpLength] == 'T':
		print('YES')
		done = True
	elif stringInput[gPos - jumpLength] == '#':
		print('NO')
		done = True
	else:
		gPos = gPos - jumpLength


def main():
	(n, k) = map(int, input().split())
	s = input()
	G = s.find('G')
	T = s.find('T')
	k = k if G < T else -k
	if abs(G - T) % k != 0:
		print('NO')
	else:
		while G != T:
			G += k
			if s[G] == '#':
				print('NO')
				return
		print('YES')
main()


(n, k) = map(int, input().strip().split())
s = input().strip()
g = s.index('G')
t = s.index('T')
if abs(t - g) % k != 0:
	print('NO')
else:
	ans = 'YES'
	for i in range(min(t, g), max(t, g) + 1, k):
		if s[i] == '#':
			ans = 'NO'
			break
	print(ans)


(a, b) = input().split()
b = int(b)
s = input()
first = 0
for i in range(0, len(s)):
	if s[i] == 'G' or s[i] == 'T':
		first = i
		break
for i in range(first + b, len(s), b):
	if s[i] == 'G' or s[i] == 'T':
		print('YES')
		exit()
	if s[i] == '#':
		print('NO')
		exit()
print('NO')


(n, k) = map(int, input().split())
s = input()
mid = '*' + s.replace('T', 'G').split('G')[1] + '*'
is_yes = False
for i in range(k, len(mid), k):
	if mid[i] == '*':
		is_yes = True
		break
	elif mid[i] == '#':
		break
print('YES' if is_yes else 'NO')


(n, k) = [int(x) for x in input().split(' ')]
sequence = list(input())
g = [sequence.index(x) for x in sequence if x == 'G']
t = [sequence.index(x) for x in sequence if x == 'T']
g = g[0]
t = t[0]
possible = False
if g == t:
	possible = True
elif g < t:
	try:
		while g <= t:
			if sequence[g + k] == 'T':
				possible = True
				break
			elif sequence[g + k] == '#':
				possible = False
				break
			else:
				g += k
	except IndexError:
		possible = False
else:
	try:
		while g >= t:
			if sequence[g - k] == 'T':
				possible = True
				break
			elif sequence[g - k] == '#':
				possible = False
				break
			else:
				g -= k
	except IndexError:
		possible = False
if possible:
	print('YES')
else:
	print('NO')


fmap = lambda f, l: list(map(f, l))
parse_int = lambda : fmap(int, input().split())
DEBUG = False
k = parse_int()[1]
s = input()
x = s.find('G')
while True:
	x += k
	if not 0 <= x < len(s):
		break
	if s[x] == '#':
		break
	if s[x] == 'T':
		print('YES')
		exit()
while True:
	x -= k
	if not 0 <= x < len(s):
		break
	if s[x] == '#':
		break
	if s[x] == 'T':
		print('YES')
		exit()
print('NO')


(n, k) = map(int, input().split())
a = str(list(input().split()))
g = a.index('G')
t = a.index('T')
if g > t:
	z = g
	g = t
	t = z
if (t - g) % k == 0:
	while g != t:
		if a[g] == '#':
			print('NO')
			break
		g = g + k
else:
	print('NO')
if g == t:
	print('YES')


(n, k) = map(int, input().split())
a = list(input())
b = a.index('G')
c = a.index('T')
if c < b:
	a[c] = 'G'
	a[b] = 'T'
	(c, b) = (b, c)
if abs(c - b) % k != 0:
	print('NO')
else:
	for i in range(b, c + 1, k):
		if a[i] == '#':
			print('NO')
			exit()
	print('YES')


(n, k) = map(int, input().split())
x = input()
pos_G = pos_T = 0
for i in range(n):
	if x[i] == 'G':
		pos_G = i
	elif x[i] == 'T':
		pos_T = i
if pos_G < pos_T:
	while pos_G + k <= pos_T:
		pos_G += k
		if pos_G == pos_T:
			print('YES')
			exit(0)
		elif x[pos_G] == '#':
			break
else:
	while pos_T + k <= pos_G:
		pos_T += k
		if pos_G == pos_T:
			print('YES')
			exit(0)
		elif x[pos_T] == '#':
			break
print('NO')


l = input().split()
l = list(map(int, l))
n = l[0]
k = l[1]
s = input()
for i in s:
	if i == 'G':
		g = s.index(i)
	elif i == 'T':
		t = s.index(i)
a = min(g, t)
b = max(g, t)
flag = 0
for i in range(a, b + 1, k):
	if s[i] == '#':
		break
	if i == b:
		flag = 1
		break
if flag == 0:
	print('NO')
else:
	print('YES')


(n, k) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
if abs(g - t) % k == 0:
	sign = 1 if g < t else -1
	while g != t:
		if s[g] == '#':
			break
		g += sign * k
if g == t:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = input()
g = a.index('G')
t = a.index('T')
obs = [i for i in range(min(g, t) + 1, max(g, t)) if a[i] == '#']
if abs(g - t) % k != 0:
	print('NO')
else:
	for i in obs:
		if abs(i - g) % k == 0:
			print('NO')
			break
	else:
		print('YES')


(n, k) = map(int, input().split())
path = input()
g = path.find('G')
t = path.find('T')
found = False
if t < g:
	if g - t < k:
		print('NO')
		exit()
	while g >= k and g >= t:
		g -= k
		if path[g] == '#':
			print('NO')
			found = True
			break
		elif path[g] == 'T':
			print('YES')
			found = True
			break
	if not found:
		print('NO')
else:
	if t - g < k:
		print('NO')
		exit()
	while g <= n - k - 1 and g <= t:
		g += k
		if path[g] == '#':
			print('NO')
			found = True
			break
		elif path[g] == 'T':
			print('YES')
			found = True
			break
	if not found:
		print('NO')


import sys
first_line = input()
second_line = input()
debug = False
n = int(first_line.split(' ')[0])
k = int(first_line.split(' ')[1])
i = -1
gt = False
for c in second_line:
	if debug:
		print(i)
	if c == 'G' or c == 'T':
		if debug:
			print('found G or T')
		if not gt:
			i = 1
			gt = True
		elif i % k == 0:
			print('YES')
			sys.exit()
		else:
			print('NO')
			sys.exit()
	elif c == '#' and gt:
		if debug:
			print('found  #')
		if i % k == 0 and i >= k:
			print('NO')
			sys.exit()
		else:
			pass
			i += 1
	elif gt:
		if debug:
			print('found .')
		i += 1
print('NO')


import sys
(n, k) = map(int, sys.stdin.readline().split())
line = sys.stdin.readline()
idx_g = line.index('G')
idx_t = line.index('T')
idx_max = max(idx_g, idx_t)
idx_min = min(idx_g, idx_t)
if (idx_max - idx_min) % k != 0:
	print('NO')
	sys.exit()
for idx in range(idx_min + k, idx_max - k + 1, k):
	if line[idx] != '.':
		print('NO')
		sys.exit()
print('YES')
sys.exit()


import copy
lst = list(map(int, input().split(' ')))
n = lst[0]
k = lst[1]
s = input()
p_G = copy.copy(s.find('G'))
p_T = copy.copy(s.find('T'))
i = 1
if abs(p_T - p_G) % k == 0:
	while not p_T == p_G:
		p_T += (p_G - p_T) // abs(p_G - p_T) * (i * k)
		if s[p_T] == '#':
			print('NO')
			break
		elif p_T == p_G:
			print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
g = 0
t = 0
for i in range(n):
	if s[i] == 'G':
		g = i
	elif s[i] == 'T':
		t = i
if g > t:
	k *= -1
	t -= 1
else:
	t += 1
yes = False
for i in range(g, t, k):
	if s[i] == '#':
		break
	if s[i] == 'T':
		yes = True
		break
if yes:
	print('YES')
else:
	print('NO')


import sys
a = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]
count = a[0]
jump = a[1]
s = sys.stdin.readline().rstrip()
grasshopper_location = s.find('G')
target_location = s.find('T')
r = 'YES'
if abs(grasshopper_location - target_location) % jump != 0:
	print('NO')
else:
	if grasshopper_location > target_location:
		i = grasshopper_location - jump
		while i > target_location:
			if s[i] == '#':
				r = 'NO'
				break
			i -= jump
	else:
		i = grasshopper_location + jump
		while i < target_location:
			if s[i] == '#':
				r = 'NO'
				break
			i += jump
	print(r)


(n, k) = map(int, input().strip().split(' '))
s = input()
g = s.index('G')
t = s.index('T')
if g < t:
	i = g
	u = 0
	while True:
		i += k
		if i == t:
			u = 1
			break
		if i > t:
			break
		if s[i] == '#':
			break
	if u == 0:
		print('NO')
	else:
		print('YES')
else:
	i = t
	u = 0
	while True:
		i += k
		if i == g:
			u = 1
			break
		if i > g:
			break
		if s[i] == '#':
			break
	if u == 0:
		print('NO')
	else:
		print('YES')


(n, k) = map(int, input().split())
a = input()
x = a.index('G')
y = a.index('T')
if (y - x) % k == 0:
	if x < y:
		p = (y - x) // k
		while p:
			x += k
			if a[x] == '#':
				print('NO')
				exit()
			p -= 1
	else:
		p = (x - y) // k
		while p:
			x -= k
			if a[x] == '#':
				print('NO')
				exit()
			p -= 1
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = list(input())
i = a.index('G')
j = a.index('T')
ans1 = a[i::-k]
ans2 = a[i::k]
for c in ans1:
	if c == 'T':
		print('YES')
		exit()
	elif c == '#':
		break
for c in ans2:
	if c == 'T':
		print('YES')
		exit()
	elif c == '#':
		break
print('NO')


(n, k) = list(map(int, input().split()))
p = list(input())
q = p.index('G')
t = p.index('T')
to = 0
pol = abs(q - t)
if pol % k != 0:
	print('NO')
elif q > t:
	for x in range(pol // k):
		if p[q - k] != '#':
			q -= k
			pass
		else:
			to = 1
			print('NO')
			break
	if to == 0:
		print('YES')
else:
	for x in range(pol // k):
		if p[q + k] != '#':
			q += k
			pass
		else:
			to = 1
			print('NO')
			break
	if to == 0:
		print('YES')


(n, k) = map(int, input().split())
s = input()
(x, y) = (s.index('G'), s.index('T'))
(x, y) = (min(x, y), max(x, y))
for i in range(x, y + 1, k):
	if s[i] == '#':
		print('NO')
		break
else:
	if i != y:
		print('NO')
	else:
		print('YES')


(_, step) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
if t < g:
	(t, g) = (g, t)
ok = True
if (t - g) % step != 0:
	ok = False
else:
	for i in range(g + step, t, step):
		if s[i] == '#':
			ok = False
			break
print(('NO', 'YES')[ok])


def can_eat(k, s):
	i = 0
	while s[i] not in 'GT':
		i += 1
	while True:
		for j in range(i + 1, i + k):
			if s[j] in 'GT':
				return False
		i += k
		if s[i] == '#':
			return False
		if s[i] in 'GT':
			return True
print('YES' if can_eat(int(input().split()[1]), input()) else 'NO')


from sys import stdin
in1 = stdin.readline().split()
in2 = list(stdin.readline())
t = None
g = None
for i in range(len(in2)):
	if in2[i] == 'G':
		g = i
for i in range(len(in2)):
	if in2[i] == 'T':
		t = i
distance = t - g
p = True
if distance % int(in1[1]) != 0:
	print('NO')
else:
	while g != t:
		if distance < 0:
			g -= int(in1[1])
			if in2[g] == '#':
				p = False
				break
		else:
			g += int(in1[1])
			if in2[g] == '#':
				p = False
				break
	if p:
		print('YES')
	else:
		print('NO')


line1 = input()
n = int(line1.split()[0])
k = int(line1.split()[1])
field = input()
for (i, c) in enumerate(field):
	if c == 'G':
		g_pos = i
	elif c == 'T':
		t_pos = i
k = -k if t_pos < g_pos else k
result = 'NO'
while True:
	if t_pos == g_pos:
		result = 'YES'
		break
	g_pos += k
	if g_pos < 0 or g_pos >= len(field):
		result = 'NO'
		break
	if field[g_pos] == '#':
		result = 'NO'
		break
print(result)


(n, k) = map(int, input().split())
a = input()
hopper = 0
insect = 0
for i in range(n):
	if a[i] == 'G':
		hopper = i
	if a[i] == 'T':
		insect = i
start = hopper
if insect < hopper:
	k = -1 * k
found = False
while start < n and start >= 0:
	if a[start] == 'T':
		found = True
	if a[start] == '#':
		break
	start += k
if found:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = input()
if a.index('G') > a.index('T'):
	a = a[::-1]
for i in range(a.index('G'), n, k):
	if a[i] == '#':
		exit(print('NO'))
	elif a[i] == 'T':
		exit(print('YES'))
print('NO')


(A, B) = map(int, input().split())
line = input()
G = line.find('G')
T = line.find('T')
gh = True
if abs(G - T) % B != 0:
	gh = False
if G < T:
	for a in range(G + B, T, B):
		if line[a] == '#':
			gh = False
			break
elif G > T:
	for a in range(G - B, T - B, -B):
		if line[a] == '#':
			gh = False
			break
if gh == True:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
(g, t) = (s.index('G'), s.index('T'))
print('NO' if abs(g - t) % k or '#' in s[min(g, t):max(g, t) + 1:k] else 'YES')


(n, k) = map(int, input().split())
s = input()
g = s.index('G')
t = s.index('T')
if g > t:
	k = -k
i = 1000
u = 0
while i > 0:
	if g != t:
		try:
			if s[g + k] != '#':
				g += k
		except:
			pass
	else:
		u += 1
		pass
	i -= 1
if u > 0:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = input()
visited = [False] * n

def dfs(i):
	if i < 0 or i >= n or visited[i] or (s[i] == '#'):
		return
	visited[i] = True
	dfs(i - k)
	dfs(i + k)
for i in range(n):
	if s[i] == 'G':
		dfs(i)
		for j in range(n):
			if s[j] == 'T':
				print('YES' if visited[j] else 'NO')


(n, k) = map(int, input().split())
s = input()
(g, t) = (s.index('G'), s.index('T'))
if t < g:
	(g, t) = (t, g)
if (t - g) % k != 0 or '#' in s[g:t:k]:
	print('NO')
else:
	print('YES')


(trash, n) = [int(x) for x in input().split()]
x = [str(x) for x in input().split()]
s = list(x[0])
done = False
for i in range(len(s)):
	if s[i] == 'T' or s[i] == 'G':
		for j in range(i + n, len(s), n):
			if s[j] == 'T' or s[j] == 'G':
				print('YES')
				done = True
				break
			if s[j] == '#':
				print('NO')
				done = True
				break
		if done:
			break
if not done:
	print('NO')


def find_object_idx(cells, symbol):
	for (idx, val) in enumerate(cells):
		if val == symbol:
			return idx
(num_cells, k) = [int(x) for x in input().split()]
cells = input()
grasshopper_idx = find_object_idx(cells, 'G')
insect_idx = find_object_idx(cells, 'T')
start_index = min(grasshopper_idx, insect_idx)
target_index = max(grasshopper_idx, insect_idx)
found = False
while start_index <= target_index and start_index < num_cells:
	if start_index == target_index:
		found = True
		break
	elif cells[start_index] == '#':
		break
	start_index += k
if found:
	print('YES')
else:
	print('NO')