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

class B:
    def __init__(self, txt: str):
        self.s: F = None
        self.x: D = None
        self.r: D = None
        self.y: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: F = None
        self.x: B = None
        self.y: A = None
        self.r: B = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.s: F = None
        self.x: D = None
        self.r: D = None
        self.y: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: F = None
        self.x: B = None
        self.y: A = None
        self.r: B = None
        self.txt = txt

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

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

h.y = f
f.s = j
f.x = m
f.r = m
f.y = g
g.p = j
m.o = g
a.u = j
a.z = j
a.x = f
a.r = f
a.y = h
j.w = h
j.u = h
j.p = h
j.r = m
j.s = g
assert m.o.p.w.txt == "h"