class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: G = None
        self.y: D = None
        self.t: B = None
        self.s: F = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: C = None
        self.p: C = None
        self.v: F = None
        self.t: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.v: H = None
        self.y: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: F = None
        self.u: F = None
        self.x: E = None
        self.v: H = None
        self.w: E = None
        self.p: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.v: H = None
        self.s: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: H = None
        self.o: B = None
        self.t: F = None
        self.u: E = None
        self.p: F = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: C = None
        self.p: C = None
        self.v: F = None
        self.t: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.v: H = None
        self.y: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: F = None
        self.u: F = None
        self.x: E = None
        self.v: H = None
        self.w: E = None
        self.p: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.v: H = None
        self.s: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: H = None
        self.o: B = None
        self.t: F = None
        self.u: E = None
        self.p: F = None
        self.txt = txt

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

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

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