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

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

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

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

l.r = e
l.w = a
l.x = c
c.q = a
e.p = a
e.s = m
e.r = m
m.p = c
m.s = e
m.r = e
n.r = m
n.w = a
n.x = a
a.q = c
g.r = e
g.w = a
g.x = c
assert m.p.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.w: B = None
        self.x: B = None
        self.txt = txt

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

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

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

l.r = e
l.w = a
l.x = c
c.q = a
e.p = a
e.s = m
e.r = m
m.p = c
m.s = e
m.r = e
n.r = m
n.w = a
n.x = a
a.q = c
g.r = e
g.w = a
g.x = c
assert m.p.q.q.q.q.q.txt == "a"