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

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

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

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

f = A("f")
n = B("n")
c = C("c")
k = D("k")
l = D("l")
h = A("h")
a = B("a")
d = A("d")
e = C("e")

f.p = n
n.t = f
n.u = a
c.z = l
k.y = e
k.p = h
l.y = c
l.p = h
h.p = n
a.t = h
a.u = n
d.p = a
e.z = l
assert d.p.u.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
c = C("c")
k = D("k")
l = D("l")
h = A("h")
a = B("a")
d = A("d")
e = C("e")

f.p = n
n.t = f
n.u = a
c.z = l
k.y = e
k.p = h
l.y = c
l.p = h
h.p = n
a.t = h
a.u = n
d.p = a
e.z = l
assert d.p.u.t.p.txt == "n"