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

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

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

m = A("m")
e = B("e")
d = C("d")
c = B("c")
l = C("l")

m.v = d
m.r = c
m.q = c
e.q = l
d.t = e
d.y = l
d.x = c
c.q = l
l.t = c
l.y = d
l.x = e
assert m.r.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: B = None
        self.q: B = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
d = C("d")
c = B("c")
l = C("l")

m.v = d
m.r = c
m.q = c
e.q = l
d.t = e
d.y = l
d.x = c
c.q = l
l.t = c
l.y = d
l.x = e
assert m.r.q.x.txt == "e"