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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: B = None
        self.o: B = None
        self.r: D = None
        self.p: A = None
        self.txt = txt

h = A("h")
g = B("g")
d = C("d")
n = D("n")
k = E("k")
a = F("a")
b = D("b")

h.o = d
g.u = k
g.p = b
g.v = d
g.q = h
d.r = g
d.z = g
n.z = k
n.o = k
n.p = k
n.t = b
k.q = n
k.z = a
a.x = d
a.y = g
a.o = g
a.r = n
a.p = h
b.z = k
b.o = k
b.p = k
b.t = n
assert n.z.q.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: B = None
        self.o: B = None
        self.r: D = None
        self.p: A = None
        self.txt = txt

h = A("h")
g = B("g")
d = C("d")
n = D("n")
k = E("k")
a = F("a")
b = D("b")

h.o = d
g.u = k
g.p = b
g.v = d
g.q = h
d.r = g
d.z = g
n.z = k
n.o = k
n.p = k
n.t = b
k.q = n
k.z = a
a.x = d
a.y = g
a.o = g
a.r = n
a.p = h
b.z = k
b.o = k
b.p = k
b.t = n
assert n.z.q.z.z.txt == "a"