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

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

class C:
    def __init__(self, txt: str):
        self.v: G = None
        self.x: F = None
        self.t: D = None
        self.r: G = None
        self.s: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: D = None
        self.u: D = None
        self.txt = txt

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

e = A("e")
a = B("a")
f = C("f")
h = D("h")
b = E("b")
d = F("d")
m = G("m")

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

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

class C:
    def __init__(self, txt: str):
        self.v: G = None
        self.x: F = None
        self.t: D = None
        self.r: G = None
        self.s: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: D = None
        self.u: D = None
        self.txt = txt

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

e = A("e")
a = B("a")
f = C("f")
h = D("h")
b = E("b")
d = F("d")
m = G("m")

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