class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: C = None
        self.u: C = None
        self.txt = txt

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

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

k = A("k")
c = B("c")
l = C("l")
e = A("e")
i = A("i")
j = B("j")
m = C("m")
b = A("b")
h = A("h")

k.x = l
k.u = l
k.r = m
c.w = l
c.x = m
l.q = m
l.t = j
e.x = m
e.r = m
e.u = m
i.x = m
i.r = l
i.u = l
j.w = l
j.x = m
m.q = l
m.t = c
b.x = m
b.r = m
b.u = l
h.x = l
h.r = m
h.u = m
assert k.u.q.t.w.t.w.t.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: C = None
        self.u: C = None
        self.txt = txt

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

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

k = A("k")
c = B("c")
l = C("l")
e = A("e")
i = A("i")
j = B("j")
m = C("m")
b = A("b")
h = A("h")

k.x = l
k.u = l
k.r = m
c.w = l
c.x = m
l.q = m
l.t = j
e.x = m
e.r = m
e.u = m
i.x = m
i.r = l
i.u = l
j.w = l
j.x = m
m.q = l
m.t = c
b.x = m
b.r = m
b.u = l
h.x = l
h.r = m
h.u = m
assert k.u.q.t.w.t.w.t.w.q.txt == "m"