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

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

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

i = A("i")
g = B("g")
n = C("n")
c = B("c")
j = B("j")
a = A("a")
e = B("e")
h = C("h")

i.o = h
i.x = n
g.q = h
g.r = i
n.z = i
c.q = n
c.r = a
j.q = n
j.r = i
a.o = h
a.x = h
e.q = h
e.r = i
h.z = i
assert c.q.z.o.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
n = C("n")
c = B("c")
j = B("j")
a = A("a")
e = B("e")
h = C("h")

i.o = h
i.x = n
g.q = h
g.r = i
n.z = i
c.q = n
c.r = a
j.q = n
j.r = i
a.o = h
a.x = h
e.q = h
e.r = i
h.z = i
assert c.q.z.o.z.x.z.txt == "i"