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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

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

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

h.y = m
h.t = d
m.u = k
m.z = f
k.w = h
d.z = n
d.p = f
d.o = k
n.y = m
n.p = k
n.x = h
f.x = k
f.z = k
assert k.w.y.z.z.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

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

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

h.y = m
h.t = d
m.u = k
m.z = f
k.w = h
d.z = n
d.p = f
d.o = k
n.y = m
n.p = k
n.x = h
f.x = k
f.z = k
assert k.w.y.z.z.w.y.txt == "m"