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

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

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

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

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

h.t = f
n.t = f
n.x = e
n.z = k
d.r = k
k.u = f
k.y = e
k.x = e
e.t = f
e.x = n
e.z = k
f.t = h
i.t = h
l.u = i
l.y = n
l.x = e
j.r = k
assert j.r.y.z.u.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

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

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

h.t = f
n.t = f
n.x = e
n.z = k
d.r = k
k.u = f
k.y = e
k.x = e
e.t = f
e.x = n
e.z = k
f.t = h
i.t = h
l.u = i
l.y = n
l.x = e
j.r = k
assert j.r.y.z.u.t.t.t.t.t.txt == "h"