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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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

g.x = c
c.z = n
c.v = n
i.v = c
k.z = c
k.u = m
k.q = n
k.v = a
m.v = i
n.y = k
n.r = k
n.q = c
n.w = c
l.v = c
a.x = c
h.v = l
assert n.w.v.w.z.txt == "n"