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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.y: F = None
        self.w: A = 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.y: B = None
        self.o: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: C = None
        self.s: C = None
        self.u: F = None
        self.p: F = None
        self.txt = txt

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

n = A("n")
j = B("j")
h = C("h")
f = D("f")
i = E("i")
k = F("k")

n.s = k
j.q = f
j.y = k
j.w = n
h.t = n
f.y = j
f.o = k
i.t = f
i.y = h
i.s = h
i.u = k
i.p = k
k.o = f
k.w = h
k.s = j
assert k.s.w.s.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.y: F = None
        self.w: A = 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.y: B = None
        self.o: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: C = None
        self.s: C = None
        self.u: F = None
        self.p: F = None
        self.txt = txt

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

n = A("n")
j = B("j")
h = C("h")
f = D("f")
i = E("i")
k = F("k")

n.s = k
j.q = f
j.y = k
j.w = n
h.t = n
f.y = j
f.o = k
i.t = f
i.y = h
i.s = h
i.u = k
i.p = k
k.o = f
k.w = h
k.s = j
assert k.s.w.s.w.t.txt == "n"