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

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

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

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

l.o = c
l.z = i
l.u = e
h.q = g
d.q = g
c.o = l
c.z = l
c.u = h
i.o = c
i.z = c
i.u = h
e.q = d
g.q = d
assert i.z.z.u.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.z: A = None
        self.u: B = None
        self.txt = txt

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

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

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

l.o = c
l.z = i
l.u = e
h.q = g
d.q = g
c.o = l
c.z = l
c.u = h
i.o = c
i.z = c
i.u = h
e.q = d
g.q = d
assert i.z.z.u.q.q.q.txt == "d"