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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: F = None
        self.t: B = None
        self.u: G = None
        self.v: D = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
n = C("n")
g = D("g")
d = E("d")
l = F("l")
i = G("i")
m = A("m")
c = G("c")
j = B("j")

h.z = g
a.z = i
n.w = m
g.o = n
d.r = j
d.q = l
d.t = a
d.u = c
d.v = g
l.x = n
l.p = a
i.y = n
m.z = g
c.y = n
j.z = i
assert a.z.y.w.z.o.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: F = None
        self.t: B = None
        self.u: G = None
        self.v: D = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
n = C("n")
g = D("g")
d = E("d")
l = F("l")
i = G("i")
m = A("m")
c = G("c")
j = B("j")

h.z = g
a.z = i
n.w = m
g.o = n
d.r = j
d.q = l
d.t = a
d.u = c
d.v = g
l.x = n
l.p = a
i.y = n
m.z = g
c.y = n
j.z = i
assert a.z.y.w.z.o.w.z.txt == "g"