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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: A = None
        self.r: A = None
        self.q: C = None
        self.w: F = None
        self.s: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: G = None
        self.p: G = None
        self.y: H = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.q: G = None
        self.p: F = None
        self.txt = txt

a = A("a")
i = B("i")
m = C("m")
n = D("n")
j = E("j")
d = F("d")
b = G("b")
g = H("g")

a.w = j
a.s = j
a.z = m
i.v = m
i.q = m
i.t = a
i.r = a
i.w = d
i.s = j
m.p = d
m.r = b
n.q = j
n.o = j
j.t = b
j.p = b
j.y = g
d.x = m
d.w = n
b.s = n
b.q = a
b.w = a
g.q = b
g.p = d
assert d.x.p.w.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: E = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: A = None
        self.r: A = None
        self.q: C = None
        self.w: F = None
        self.s: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: G = None
        self.p: G = None
        self.y: H = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.q: G = None
        self.p: F = None
        self.txt = txt

a = A("a")
i = B("i")
m = C("m")
n = D("n")
j = E("j")
d = F("d")
b = G("b")
g = H("g")

a.w = j
a.s = j
a.z = m
i.v = m
i.q = m
i.t = a
i.r = a
i.w = d
i.s = j
m.p = d
m.r = b
n.q = j
n.o = j
j.t = b
j.p = b
j.y = g
d.x = m
d.w = n
b.s = n
b.q = a
b.w = a
g.q = b
g.p = d
assert d.x.p.w.q.y.txt == "g"