class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.txt = txt

n = A("n")
g = B("g")
l = C("l")
k = B("k")
b = C("b")
h = C("h")
m = A("m")
d = A("d")
j = A("j")

n.t = j
n.r = d
g.x = j
l.q = k
l.p = m
k.x = j
b.q = g
b.p = m
h.q = k
h.p = n
m.t = n
m.r = d
d.t = m
d.r = j
j.t = m
j.r = d
assert g.x.t.r.r.r.t.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.txt = txt

n = A("n")
g = B("g")
l = C("l")
k = B("k")
b = C("b")
h = C("h")
m = A("m")
d = A("d")
j = A("j")

n.t = j
n.r = d
g.x = j
l.q = k
l.p = m
k.x = j
b.q = g
b.p = m
h.q = k
h.p = n
m.t = n
m.r = d
d.t = m
d.r = j
j.t = m
j.r = d
assert g.x.t.r.r.r.t.t.r.txt == "d"