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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: H = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: A = None
        self.z: D = None
        self.o: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: B = None
        self.s: G = None
        self.t: G = None
        self.txt = txt

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

j.q = n
j.x = f
d.s = f
e.w = j
e.p = d
i.s = j
i.o = j
i.x = d
i.y = e
i.w = b
i.p = n
f.w = e
h.t = e
h.z = b
n.w = d
n.q = j
n.z = i
n.o = b
b.x = d
b.w = d
b.s = n
b.t = n
assert d.s.w.p.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: G = None
        self.x: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: H = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: A = None
        self.z: D = None
        self.o: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: B = None
        self.s: G = None
        self.t: G = None
        self.txt = txt

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

j.q = n
j.x = f
d.s = f
e.w = j
e.p = d
i.s = j
i.o = j
i.x = d
i.y = e
i.w = b
i.p = n
f.w = e
h.t = e
h.z = b
n.w = d
n.q = j
n.z = i
n.o = b
b.x = d
b.w = d
b.s = n
b.t = n
assert d.s.w.p.s.w.txt == "e"