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

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

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

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

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

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

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

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

k.s = d
k.u = l
f.w = a
f.z = c
f.p = j
l.w = k
j.w = c
m.w = f
m.z = c
m.p = j
d.w = k
c.s = j
c.u = l
a.w = f
a.z = k
a.p = d
assert j.w.u.w.u.txt == "l"