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

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

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

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

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

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

a = A("a")
h = B("h")
n = C("n")
j = D("j")
g = E("g")
m = F("m")

a.y = h
a.s = h
a.r = h
a.p = j
a.q = g
h.s = j
h.x = j
h.q = g
h.z = g
h.v = n
h.u = a
n.u = a
j.z = m
g.y = h
g.q = h
m.z = h
m.y = g
m.v = g
m.w = g
assert m.w.y.x.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: B = None
        self.p: D = None
        self.q: E = None
        self.r: B = None
        self.txt = txt

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

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

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

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

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

a = A("a")
h = B("h")
n = C("n")
j = D("j")
g = E("g")
m = F("m")

a.y = h
a.s = h
a.r = h
a.p = j
a.q = g
h.s = j
h.x = j
h.q = g
h.z = g
h.v = n
h.u = a
n.u = a
j.z = m
g.y = h
g.q = h
m.z = h
m.y = g
m.v = g
m.w = g
assert m.w.y.x.z.z.txt == "h"