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

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

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

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

j = A("j")
k = B("k")
c = C("c")
a = D("a")
i = D("i")
l = A("l")
g = D("g")
n = D("n")
f = B("f")
d = C("d")

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

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

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

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

j = A("j")
k = B("k")
c = C("c")
a = D("a")
i = D("i")
l = A("l")
g = D("g")
n = D("n")
f = B("f")
d = C("d")

j.r = l
j.p = n
k.z = l
k.s = j
k.y = i
c.z = j
c.t = d
c.w = d
a.w = f
i.w = k
l.r = j
l.p = i
g.w = k
n.w = k
f.z = j
f.s = l
f.y = a
d.z = l
d.t = c
d.w = c
assert k.z.r.r.p.txt == "i"