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

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

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

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

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

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

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

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

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

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

k.x = d
n.q = k
n.r = d
g.o = i
g.x = i
g.t = k
a.v = n
a.t = n
a.z = i
a.u = d
d.v = n
d.t = n
d.z = g
d.u = a
i.o = g
i.x = g
i.t = k
assert a.z.x.t.x.u.txt == "a"