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

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

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

e = A("e")
f = B("f")
i = C("i")
h = C("h")
k = C("k")
a = A("a")
j = A("j")
m = C("m")
d = C("d")
b = C("b")

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

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

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

e = A("e")
f = B("f")
i = C("i")
h = C("h")
k = C("k")
a = A("a")
j = A("j")
m = C("m")
d = C("d")
b = C("b")

e.w = b
e.r = b
f.t = j
f.q = j
f.u = j
i.q = j
h.q = a
k.q = a
a.w = h
a.r = i
j.w = d
j.r = k
m.q = j
d.q = e
b.q = a
assert j.w.q.r.txt == "b"