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

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

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

m = A("m")
d = B("d")
j = C("j")
a = C("a")
i = C("i")
g = C("g")
e = A("e")
l = B("l")

m.v = d
m.r = d
d.p = l
d.t = l
d.u = j
j.q = e
a.q = e
i.q = e
g.q = e
e.v = d
e.r = l
l.p = d
l.t = d
l.u = j
assert d.t.u.q.r.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
j = C("j")
a = C("a")
i = C("i")
g = C("g")
e = A("e")
l = B("l")

m.v = d
m.r = d
d.p = l
d.t = l
d.u = j
j.q = e
a.q = e
i.q = e
g.q = e
e.v = d
e.r = l
l.p = d
l.t = d
l.u = j
assert d.t.u.q.r.p.p.txt == "l"