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

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

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

d = A("d")
a = B("a")
i = C("i")
j = C("j")

d.w = a
a.q = d
a.x = d
i.t = j
i.o = a
i.s = a
j.t = i
j.o = a
j.s = a
assert j.t.t.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
i = C("i")
j = C("j")

d.w = a
a.q = d
a.x = d
i.t = j
i.o = a
i.s = a
j.t = i
j.o = a
j.s = a
assert j.t.t.s.x.txt == "d"