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

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

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

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

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

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

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

k.s = n
h.u = m
h.v = k
h.w = e
m.y = n
m.o = e
e.x = k
d.y = k
n.x = m
n.v = h
n.y = d
assert d.y.s.v.w.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

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

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

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

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

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

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

k.s = n
h.u = m
h.v = k
h.w = e
m.y = n
m.o = e
e.x = k
d.y = k
n.x = m
n.v = h
n.y = d
assert d.y.s.v.w.x.s.txt == "n"