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

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

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

m = A("m")
e = B("e")
b = C("b")
g = C("g")
i = B("i")
n = A("n")
a = B("a")
c = A("c")

m.x = i
m.z = b
e.q = n
e.p = n
e.t = i
b.p = m
b.z = g
g.p = c
g.z = b
i.q = m
i.t = e
i.p = c
n.x = i
n.z = b
a.q = m
a.t = e
a.p = n
c.x = e
c.z = b
assert i.p.x.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: C = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
b = C("b")
g = C("g")
i = B("i")
n = A("n")
a = B("a")
c = A("c")

m.x = i
m.z = b
e.q = n
e.p = n
e.t = i
b.p = m
b.z = g
g.p = c
g.z = b
i.q = m
i.t = e
i.p = c
n.x = i
n.z = b
a.q = m
a.t = e
a.p = n
c.x = e
c.z = b
assert i.p.x.q.x.q.txt == "m"