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

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

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

e = A("e")
k = B("k")
l = C("l")
d = B("d")
n = B("n")
f = A("f")
c = A("c")
i = A("i")
j = B("j")
m = C("m")

e.r = m
k.p = i
k.u = f
l.q = d
l.t = k
d.p = e
d.u = f
n.p = f
n.u = f
f.r = l
c.r = m
i.r = m
j.p = i
j.u = c
m.q = n
m.t = k
assert j.p.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
l = C("l")
d = B("d")
n = B("n")
f = A("f")
c = A("c")
i = A("i")
j = B("j")
m = C("m")

e.r = m
k.p = i
k.u = f
l.q = d
l.t = k
d.p = e
d.u = f
n.p = f
n.u = f
f.r = l
c.r = m
i.r = m
j.p = i
j.u = c
m.q = n
m.t = k
assert j.p.r.t.txt == "k"