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

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

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

d = A("d")
c = B("c")
j = C("j")

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

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

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

d = A("d")
c = B("c")
j = C("j")

d.o = c
c.w = d
c.q = d
j.z = d
j.o = c
j.u = c
assert c.q.o.w.txt == "d"