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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

e = A("e")
f = B("f")
k = C("k")
m = D("m")
i = E("i")
h = F("h")
g = D("g")

e.y = i
e.p = k
f.v = e
f.o = e
f.t = e
f.y = i
f.w = g
k.w = e
k.t = m
m.x = i
m.o = g
m.z = g
i.o = f
h.y = k
g.x = i
g.o = m
g.z = m
assert m.x.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.p: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

e = A("e")
f = B("f")
k = C("k")
m = D("m")
i = E("i")
h = F("h")
g = D("g")

e.y = i
e.p = k
f.v = e
f.o = e
f.t = e
f.y = i
f.w = g
k.w = e
k.t = m
m.x = i
m.o = g
m.z = g
i.o = f
h.y = k
g.x = i
g.o = m
g.z = m
assert m.x.o.w.txt == "g"