class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: B = None
        self.x: B = None
        self.s: E = None
        self.t: E = None
        self.y: E = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.q: F = None
        self.y: A = None
        self.o: B = None
        self.w: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: C = None
        self.u: B = None
        self.y: B = None
        self.o: B = None
        self.s: G = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: D = None
        self.y: C = None
        self.q: D = None
        self.txt = txt

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

g = A("g")
f = B("f")
i = C("i")
n = D("n")
k = E("k")
a = F("a")
h = G("h")

g.q = f
g.p = f
g.x = f
g.z = f
g.s = k
g.t = k
g.y = k
f.r = g
i.s = a
i.q = a
i.y = g
i.o = f
i.w = h
n.p = f
n.u = f
n.y = f
n.o = f
n.v = i
n.s = h
k.t = h
a.w = k
a.p = n
a.q = n
a.y = i
h.o = a
h.s = g
assert g.x.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: B = None
        self.x: B = None
        self.s: E = None
        self.t: E = None
        self.y: E = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: F = None
        self.q: F = None
        self.y: A = None
        self.o: B = None
        self.w: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: C = None
        self.u: B = None
        self.y: B = None
        self.o: B = None
        self.s: G = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: D = None
        self.y: C = None
        self.q: D = None
        self.txt = txt

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

g = A("g")
f = B("f")
i = C("i")
n = D("n")
k = E("k")
a = F("a")
h = G("h")

g.q = f
g.p = f
g.x = f
g.z = f
g.s = k
g.t = k
g.y = k
f.r = g
i.s = a
i.q = a
i.y = g
i.o = f
i.w = h
n.p = f
n.u = f
n.y = f
n.o = f
n.v = i
n.s = h
k.t = h
a.w = k
a.p = n
a.q = n
a.y = i
h.o = a
h.s = g
assert g.x.r.z.txt == "f"