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

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

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

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

m = A("m")
l = B("l")
g = C("g")
f = D("f")
h = D("h")
d = B("d")
n = C("n")
c = A("c")

m.r = d
m.p = g
l.w = d
g.t = f
g.u = n
f.x = g
f.y = d
f.v = d
f.p = h
h.x = g
h.y = l
h.v = l
h.p = f
d.w = l
n.t = f
n.u = g
c.r = l
c.p = g
assert c.r.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: C = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
g = C("g")
f = D("f")
h = D("h")
d = B("d")
n = C("n")
c = A("c")

m.r = d
m.p = g
l.w = d
g.t = f
g.u = n
f.x = g
f.y = d
f.v = d
f.p = h
h.x = g
h.y = l
h.v = l
h.p = f
d.w = l
n.t = f
n.u = g
c.r = l
c.p = g
assert c.r.w.w.txt == "l"