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

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

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

d = A("d")
k = B("k")
b = C("b")

d.z = k
d.u = k
d.o = k
k.r = b
k.u = d
b.w = d
b.y = d
assert b.y.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: B = None
        self.o: B = None
        self.txt = txt

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

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

d = A("d")
k = B("k")
b = C("b")

d.z = k
d.u = k
d.o = k
k.r = b
k.u = d
b.w = d
b.y = d
assert b.y.o.u.txt == "d"