class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: D = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: E = None
        self.x: A = None
        self.p: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: F = None
        self.q: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: C = None
        self.x: E = None
        self.o: B = None
        self.w: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
d = C("d")
i = D("i")
n = E("n")
h = F("h")

a.o = f
a.u = i
a.w = i
f.u = d
f.p = d
f.s = n
f.x = a
d.x = i
d.z = h
d.q = a
i.p = a
i.z = d
i.x = n
i.o = f
i.w = f
n.z = h
n.o = h
n.s = f
n.y = a
n.u = i
h.y = a
assert n.z.y.w.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: D = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: E = None
        self.x: A = None
        self.p: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: F = None
        self.q: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: C = None
        self.x: E = None
        self.o: B = None
        self.w: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
d = C("d")
i = D("i")
n = E("n")
h = F("h")

a.o = f
a.u = i
a.w = i
f.u = d
f.p = d
f.s = n
f.x = a
d.x = i
d.z = h
d.q = a
i.p = a
i.z = d
i.x = n
i.o = f
i.w = f
n.z = h
n.o = h
n.s = f
n.y = a
n.u = i
h.y = a
assert n.z.y.w.p.w.txt == "i"