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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: G = None
        self.o: E = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.q: E = None
        self.y: D = None
        self.w: A = None
        self.t: G = None
        self.z: G = None
        self.u: D = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: G = None
        self.o: E = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.q: E = None
        self.y: D = None
        self.w: A = None
        self.t: G = None
        self.z: G = None
        self.u: D = None
        self.txt = txt

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

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

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