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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: D = None
        self.x: C = None
        self.s: B = None
        self.txt = txt

h = A("h")
a = B("a")
k = C("k")
i = D("i")
d = B("d")
b = D("b")
c = C("c")
j = A("j")
l = C("l")
e = A("e")

h.p = l
a.y = e
a.w = d
a.x = i
a.r = j
k.z = d
k.r = c
k.p = b
k.w = h
i.u = h
i.w = b
i.x = c
i.s = a
d.y = h
d.w = a
d.x = b
d.r = j
b.u = j
b.w = i
b.x = k
b.s = a
c.z = d
c.r = k
c.p = b
c.w = e
j.p = l
l.z = d
l.r = k
l.p = i
l.w = j
e.p = c
assert b.w.w.x.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: D = None
        self.x: C = None
        self.s: B = None
        self.txt = txt

h = A("h")
a = B("a")
k = C("k")
i = D("i")
d = B("d")
b = D("b")
c = C("c")
j = A("j")
l = C("l")
e = A("e")

h.p = l
a.y = e
a.w = d
a.x = i
a.r = j
k.z = d
k.r = c
k.p = b
k.w = h
i.u = h
i.w = b
i.x = c
i.s = a
d.y = h
d.w = a
d.x = b
d.r = j
b.u = j
b.w = i
b.x = k
b.s = a
c.z = d
c.r = k
c.p = b
c.w = e
j.p = l
l.z = d
l.r = k
l.p = i
l.w = j
e.p = c
assert b.w.w.x.r.r.txt == "k"