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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: D = None
        self.r: C = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
e = C("e")
k = D("k")
f = D("f")
n = A("n")
i = C("i")

h.p = n
h.o = l
l.u = e
l.r = e
l.q = k
e.x = l
e.w = k
e.t = h
k.y = n
f.y = n
n.p = h
n.o = l
i.x = l
i.w = f
i.t = h
assert k.y.o.u.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: D = None
        self.r: C = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
e = C("e")
k = D("k")
f = D("f")
n = A("n")
i = C("i")

h.p = n
h.o = l
l.u = e
l.r = e
l.q = k
e.x = l
e.w = k
e.t = h
k.y = n
f.y = n
n.p = h
n.o = l
i.x = l
i.w = f
i.t = h
assert k.y.o.u.t.o.r.txt == "e"