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

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

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

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

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

c.u = h
c.z = b
d.u = a
d.t = a
d.y = b
g.y = l
n.z = h
b.u = j
b.z = c
k.u = g
k.t = g
k.y = c
j.y = a
h.y = g
l.y = j
a.y = l
assert d.y.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: A = None
        self.txt = txt

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

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

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

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

c.u = h
c.z = b
d.u = a
d.t = a
d.y = b
g.y = l
n.z = h
b.u = j
b.z = c
k.u = g
k.t = g
k.y = c
j.y = a
h.y = g
l.y = j
a.y = l
assert d.y.z.u.txt == "h"