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

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

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

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

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

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

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

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

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

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

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

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

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

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

c.z = n
a.y = h
n.t = c
f.u = c
f.p = n
b.u = c
k.x = d
k.z = f
k.t = n
h.u = c
h.p = n
m.x = d
m.z = h
m.t = n
d.y = h
assert b.u.z.t.z.t.z.t.z.txt == "n"