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

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

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

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

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

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

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

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

k.u = j
k.w = j
f.z = j
a.q = d
a.o = f
d.q = a
d.o = f
j.u = k
j.w = k
assert d.o.z.w.w.txt == "j"