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

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

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

class D:
    def __init__(self, txt: str):
        self.r: F = None
        self.w: C = None
        self.txt = txt

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

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

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

e = A("e")
d = B("d")
c = C("c")
m = D("m")
i = E("i")
f = F("f")
b = G("b")
n = F("n")
l = D("l")
h = G("h")

e.r = m
d.q = e
c.r = d
c.y = i
c.t = h
c.p = n
c.x = m
m.r = f
m.w = c
i.q = e
f.w = d
f.y = d
f.z = d
f.t = d
f.q = c
f.x = n
f.s = h
b.s = c
n.w = d
n.y = d
n.z = d
n.t = d
n.q = c
n.x = f
n.s = b
l.r = n
l.w = c
h.s = c
assert m.r.t.q.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: F = None
        self.w: C = None
        self.txt = txt

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

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

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

e = A("e")
d = B("d")
c = C("c")
m = D("m")
i = E("i")
f = F("f")
b = G("b")
n = F("n")
l = D("l")
h = G("h")

e.r = m
d.q = e
c.r = d
c.y = i
c.t = h
c.p = n
c.x = m
m.r = f
m.w = c
i.q = e
f.w = d
f.y = d
f.z = d
f.t = d
f.q = c
f.x = n
f.s = h
b.s = c
n.w = d
n.y = d
n.z = d
n.t = d
n.q = c
n.x = f
n.s = b
l.r = n
l.w = c
h.s = c
assert m.r.t.q.r.w.txt == "c"