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

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

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

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

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

c.p = l
c.r = l
f.y = l
f.z = m
d.r = c
d.z = n
d.p = m
d.w = j
l.t = j
g.r = c
g.z = f
g.p = m
g.w = j
m.r = c
m.z = f
m.p = d
m.w = n
j.y = l
j.z = g
n.y = l
n.z = d
assert d.z.z.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

c.p = l
c.r = l
f.y = l
f.z = m
d.r = c
d.z = n
d.p = m
d.w = j
l.t = j
g.r = c
g.z = f
g.p = m
g.w = j
m.r = c
m.z = f
m.p = d
m.w = n
j.y = l
j.z = g
n.y = l
n.z = d
assert d.z.z.z.y.txt == "l"