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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: A = None
        self.v: G = None
        self.u: F = None
        self.w: F = None
        self.txt = txt

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: E = None
        self.x: G = None
        self.q: G = None
        self.txt = txt

k = A("k")
g = B("g")
m = C("m")
e = D("e")
l = E("l")
h = F("h")
c = G("c")
f = H("f")

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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: A = None
        self.v: G = None
        self.u: F = None
        self.w: F = None
        self.txt = txt

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: E = None
        self.x: G = None
        self.q: G = None
        self.txt = txt

k = A("k")
g = B("g")
m = C("m")
e = D("e")
l = E("l")
h = F("h")
c = G("c")
f = H("f")

k.x = m
k.p = m
k.q = l
k.u = h
g.o = f
g.y = e
g.x = k
m.z = e
m.x = k
m.v = c
m.u = h
m.w = h
e.o = l
l.t = k
l.u = g
h.u = m
c.x = k
c.p = k
c.q = e
c.o = f
f.r = k
f.v = l
f.x = c
f.q = c
assert h.u.v.x.txt == "k"