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

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

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

d = A("d")
l = B("l")
i = C("i")
h = C("h")
j = B("j")

d.t = h
d.z = j
d.o = i
l.y = j
l.q = d
l.x = i
i.r = h
h.r = i
j.y = l
j.q = d
j.x = i
assert j.y.x.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: B = None
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
i = C("i")
h = C("h")
j = B("j")

d.t = h
d.z = j
d.o = i
l.y = j
l.q = d
l.x = i
i.r = h
h.r = i
j.y = l
j.q = d
j.x = i
assert j.y.x.r.r.txt == "i"