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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: H = None
        self.x: D = None
        self.y: F = None
        self.txt = txt

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.x: F = None
        self.v: B = None
        self.w: A = None
        self.t: D = None
        self.q: A = None
        self.z: F = None
        self.txt = txt

a = A("a")
c = B("c")
j = C("j")
d = D("d")
i = E("i")
g = F("g")
e = G("e")
h = H("h")

a.x = g
c.p = d
c.x = i
j.t = d
j.x = d
j.q = h
j.y = g
d.u = e
d.w = j
d.s = a
d.q = h
i.r = c
i.t = h
i.s = e
g.p = e
e.s = d
e.o = i
e.w = g
h.x = g
h.z = g
h.v = c
h.w = a
h.q = a
h.t = d
assert e.s.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: H = None
        self.x: D = None
        self.y: F = None
        self.txt = txt

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.x: F = None
        self.v: B = None
        self.w: A = None
        self.t: D = None
        self.q: A = None
        self.z: F = None
        self.txt = txt

a = A("a")
c = B("c")
j = C("j")
d = D("d")
i = E("i")
g = F("g")
e = G("e")
h = H("h")

a.x = g
c.p = d
c.x = i
j.t = d
j.x = d
j.q = h
j.y = g
d.u = e
d.w = j
d.s = a
d.q = h
i.r = c
i.t = h
i.s = e
g.p = e
e.s = d
e.o = i
e.w = g
h.x = g
h.z = g
h.v = c
h.w = a
h.q = a
h.t = d
assert e.s.q.x.txt == "g"