class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.w: B = None
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: B = None
        self.v: A = None
        self.z: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: A = None
        self.q: C = None
        self.txt = txt

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

a.s = d
a.w = m
a.y = e
f.y = m
h.p = e
h.r = m
h.z = m
h.v = a
n.x = e
e.o = n
d.y = a
d.s = a
d.q = h
m.y = f
k.x = e
assert k.x.o.x.o.x.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.w: B = None
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: B = None
        self.v: A = None
        self.z: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: A = None
        self.q: C = None
        self.txt = txt

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

a.s = d
a.w = m
a.y = e
f.y = m
h.p = e
h.r = m
h.z = m
h.v = a
n.x = e
e.o = n
d.y = a
d.s = a
d.q = h
m.y = f
k.x = e
assert k.x.o.x.o.x.o.x.o.txt == "n"