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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: D = None
        self.o: D = None
        self.p: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

m.w = i
m.s = h
n.y = i
n.w = a
n.t = a
n.q = m
h.q = m
h.r = i
h.o = i
h.x = i
h.p = b
i.y = n
i.s = a
a.s = m
a.y = m
a.w = i
f.u = m
e.u = m
b.q = m
b.r = i
b.o = i
b.x = i
b.p = h
assert a.y.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: D = None
        self.o: D = None
        self.p: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

m.w = i
m.s = h
n.y = i
n.w = a
n.t = a
n.q = m
h.q = m
h.r = i
h.o = i
h.x = i
h.p = b
i.y = n
i.s = a
a.s = m
a.y = m
a.w = i
f.u = m
e.u = m
b.q = m
b.r = i
b.o = i
b.x = i
b.p = h
assert a.y.w.s.txt == "a"