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

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

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

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

m = A("m")
d = B("d")
a = C("a")
l = D("l")
j = C("j")
c = C("c")
n = B("n")
f = D("f")

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

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

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

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

m = A("m")
d = B("d")
a = C("a")
l = D("l")
j = C("j")
c = C("c")
n = B("n")
f = D("f")

m.p = a
m.r = n
d.y = n
d.q = n
d.w = l
d.p = f
a.t = c
a.y = f
l.w = j
l.t = f
l.x = f
j.t = c
j.y = l
c.t = j
c.y = l
n.y = d
n.q = d
n.w = f
n.p = f
f.w = j
f.t = l
f.x = l
assert d.p.x.x.w.y.txt == "l"