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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: D = None
        self.o: D = None
        self.s: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.w: A = None
        self.txt = txt

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

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

j.o = h
j.t = n
n.w = a
a.r = j
a.w = b
a.o = b
a.s = f
b.s = j
f.z = b
f.w = j
h.p = n
h.o = j
h.x = a
m.r = j
m.w = b
m.o = b
m.s = f
assert m.s.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: F = None
        self.t: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: D = None
        self.o: D = None
        self.s: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.w: A = None
        self.txt = txt

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

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

j.o = h
j.t = n
n.w = a
a.r = j
a.w = b
a.o = b
a.s = f
b.s = j
f.z = b
f.w = j
h.p = n
h.o = j
h.x = a
m.r = j
m.w = b
m.o = b
m.s = f
assert m.s.w.t.txt == "n"