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

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

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

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

h = A("h")
d = B("d")
n = C("n")
i = D("i")
k = B("k")
m = D("m")
a = A("a")

h.y = a
h.u = i
d.y = h
d.t = k
d.v = m
n.z = a
n.u = k
n.w = k
n.x = i
i.y = d
i.o = m
i.u = k
k.y = h
k.t = d
k.v = i
m.y = d
m.o = i
m.u = k
a.y = h
a.u = i
assert h.u.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: D = None
        self.txt = txt

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

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

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

h = A("h")
d = B("d")
n = C("n")
i = D("i")
k = B("k")
m = D("m")
a = A("a")

h.y = a
h.u = i
d.y = h
d.t = k
d.v = m
n.z = a
n.u = k
n.w = k
n.x = i
i.y = d
i.o = m
i.u = k
k.y = h
k.t = d
k.v = i
m.y = d
m.o = i
m.u = k
a.y = h
a.u = i
assert h.u.o.y.txt == "d"