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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: D = None
        self.t: E = None
        self.r: H = None
        self.u: E = None
        self.z: G = None
        self.v: G = None
        self.q: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: F = None
        self.t: H = None
        self.r: B = None
        self.q: H = None
        self.x: F = None
        self.o: B = None
        self.u: F = None
        self.p: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: B = None
        self.q: A = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

m = A("m")
e = B("e")
b = C("b")
c = D("c")
f = E("f")
g = F("g")
n = G("n")
i = H("i")

m.q = g
e.u = g
e.s = f
b.x = m
b.p = c
b.t = f
b.u = f
b.q = f
b.r = i
b.z = n
b.v = n
c.s = g
c.x = g
c.u = g
c.t = i
c.q = i
c.r = e
c.o = e
c.p = e
f.z = g
f.q = e
f.t = i
g.y = e
g.p = e
g.q = m
n.y = f
n.r = i
i.p = e
assert g.y.u.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: D = None
        self.t: E = None
        self.r: H = None
        self.u: E = None
        self.z: G = None
        self.v: G = None
        self.q: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: F = None
        self.t: H = None
        self.r: B = None
        self.q: H = None
        self.x: F = None
        self.o: B = None
        self.u: F = None
        self.p: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: B = None
        self.q: A = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

m = A("m")
e = B("e")
b = C("b")
c = D("c")
f = E("f")
g = F("g")
n = G("n")
i = H("i")

m.q = g
e.u = g
e.s = f
b.x = m
b.p = c
b.t = f
b.u = f
b.q = f
b.r = i
b.z = n
b.v = n
c.s = g
c.x = g
c.u = g
c.t = i
c.q = i
c.r = e
c.o = e
c.p = e
f.z = g
f.q = e
f.t = i
g.y = e
g.p = e
g.q = m
n.y = f
n.r = i
i.p = e
assert g.y.u.q.q.txt == "g"