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

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

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

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

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

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

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

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

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