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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: D = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: D = None
        self.s: D = None
        self.v: C = None
        self.txt = txt

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

e = A("e")
f = B("f")
k = C("k")
c = D("c")
d = D("d")
m = B("m")
a = A("a")
b = C("b")
n = A("n")

e.z = n
e.t = n
f.u = k
f.q = c
f.s = b
k.q = a
k.w = d
k.s = c
k.v = b
c.s = d
d.s = c
m.u = k
m.q = c
m.s = b
a.z = e
a.t = n
b.q = e
b.w = d
b.s = d
b.v = k
n.z = a
n.t = e
assert a.z.z.z.z.t.t.t.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: D = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: D = None
        self.s: D = None
        self.v: C = None
        self.txt = txt

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

e = A("e")
f = B("f")
k = C("k")
c = D("c")
d = D("d")
m = B("m")
a = A("a")
b = C("b")
n = A("n")

e.z = n
e.t = n
f.u = k
f.q = c
f.s = b
k.q = a
k.w = d
k.s = c
k.v = b
c.s = d
d.s = c
m.u = k
m.q = c
m.s = b
a.z = e
a.t = n
b.q = e
b.w = d
b.s = d
b.v = k
n.z = a
n.t = e
assert a.z.z.z.z.t.t.t.z.z.txt == "e"