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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.o: A = None
        self.q: E = None
        self.z: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: H = None
        self.o: H = None
        self.z: H = None
        self.x: F = None
        self.p: B = None
        self.q: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.y: H = None
        self.u: F = None
        self.r: H = None
        self.v: A = None
        self.x: C = None
        self.q: A = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.o: A = None
        self.q: E = None
        self.z: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: H = None
        self.o: H = None
        self.z: H = None
        self.x: F = None
        self.p: B = None
        self.q: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.y: H = None
        self.u: F = None
        self.r: H = None
        self.v: A = None
        self.x: C = None
        self.q: A = None
        self.txt = txt

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

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

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