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

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

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

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

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

n.x = b
n.u = i
c.v = a
b.z = n
i.x = b
i.t = b
a.x = b
a.t = b
h.v = i
e.v = a
k.v = i
g.x = b
g.u = a
l.x = b
l.u = i
assert b.z.x.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: D = None
        self.txt = txt

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

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

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

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

n.x = b
n.u = i
c.v = a
b.z = n
i.x = b
i.t = b
a.x = b
a.t = b
h.v = i
e.v = a
k.v = i
g.x = b
g.u = a
l.x = b
l.u = i
assert b.z.x.z.x.z.txt == "n"