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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: C = None
        self.s: D = None
        self.x: D = None
        self.q: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.s: A = None
        self.z: B = None
        self.x: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: E = None
        self.u: E = None
        self.y: B = None
        self.s: H = None
        self.r: D = None
        self.w: H = None
        self.txt = txt

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

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

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

m.q = c
m.y = d
g.w = d
g.o = d
g.s = a
g.x = a
g.q = a
d.o = b
d.x = b
d.s = m
d.z = g
a.r = d
a.u = i
a.o = g
a.x = c
a.q = c
a.z = m
a.w = j
c.o = g
c.x = b
c.y = m
b.x = d
b.z = c
b.u = c
b.y = g
b.s = i
b.w = i
b.r = a
j.p = a
i.r = j
assert d.o.u.o.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: C = None
        self.s: D = None
        self.x: D = None
        self.q: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.s: A = None
        self.z: B = None
        self.x: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: E = None
        self.u: E = None
        self.y: B = None
        self.s: H = None
        self.r: D = None
        self.w: H = None
        self.txt = txt

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

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

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

m.q = c
m.y = d
g.w = d
g.o = d
g.s = a
g.x = a
g.q = a
d.o = b
d.x = b
d.s = m
d.z = g
a.r = d
a.u = i
a.o = g
a.x = c
a.q = c
a.z = m
a.w = j
c.o = g
c.x = b
c.y = m
b.x = d
b.z = c
b.u = c
b.y = g
b.s = i
b.w = i
b.r = a
j.p = a
i.r = j
assert d.o.u.o.q.r.txt == "d"