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

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

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

l = A("l")
j = B("j")
e = C("e")
a = C("a")
d = C("d")
k = A("k")
f = B("f")

l.u = d
l.p = a
j.w = f
j.q = e
e.u = f
a.u = f
d.u = j
k.u = a
k.p = a
f.w = j
f.q = e
assert j.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
e = C("e")
a = C("a")
d = C("d")
k = A("k")
f = B("f")

l.u = d
l.p = a
j.w = f
j.q = e
e.u = f
a.u = f
d.u = j
k.u = a
k.p = a
f.w = j
f.q = e
assert j.q.u.q.txt == "e"