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

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

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

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

m.u = g
m.x = g
m.r = e
e.u = c
e.s = m
i.q = e
i.p = e
i.y = e
g.u = m
g.x = m
g.r = e
c.q = e
c.p = e
c.y = e
n.q = e
n.p = e
n.y = e
assert e.u.q.u.q.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: B = None
        self.x: A = None
        self.txt = txt

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

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

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

m.u = g
m.x = g
m.r = e
e.u = c
e.s = m
i.q = e
i.p = e
i.y = e
g.u = m
g.x = m
g.r = e
c.q = e
c.p = e
c.y = e
n.q = e
n.p = e
n.y = e
assert e.u.q.u.q.u.p.txt == "e"