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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: E = None
        self.z: A = None
        self.w: C = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: F = None
        self.p: B = None
        self.q: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

j.p = f
a.t = e
h.q = j
h.z = e
e.q = j
e.z = j
e.s = d
e.w = h
e.p = h
f.w = d
f.s = c
f.p = a
f.q = m
c.s = e
m.y = j
m.p = k
m.z = d
d.w = f
d.s = c
d.p = a
d.q = m
k.s = e
assert d.p.t.z.p.w.q.y.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: E = None
        self.z: A = None
        self.w: C = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: E = None
        self.s: F = None
        self.p: B = None
        self.q: G = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

j.p = f
a.t = e
h.q = j
h.z = e
e.q = j
e.z = j
e.s = d
e.w = h
e.p = h
f.w = d
f.s = c
f.p = a
f.q = m
c.s = e
m.y = j
m.p = k
m.z = d
d.w = f
d.s = c
d.p = a
d.q = m
k.s = e
assert d.p.t.z.p.w.q.y.p.p.txt == "a"