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

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

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

i = A("i")
b = B("b")
h = C("h")
g = A("g")
l = C("l")
m = B("m")
a = C("a")
k = B("k")

i.o = k
i.q = g
b.y = k
b.z = l
h.x = i
h.q = l
g.o = m
g.q = i
l.x = g
l.q = h
m.y = b
m.z = l
a.x = g
a.q = h
k.y = m
k.z = h
assert h.x.o.z.x.o.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: A = None
        self.txt = txt

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

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

i = A("i")
b = B("b")
h = C("h")
g = A("g")
l = C("l")
m = B("m")
a = C("a")
k = B("k")

i.o = k
i.q = g
b.y = k
b.z = l
h.x = i
h.q = l
g.o = m
g.q = i
l.x = g
l.q = h
m.y = b
m.z = l
a.x = g
a.q = h
k.y = m
k.z = h
assert h.x.o.z.x.o.z.q.txt == "l"