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

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.z: D = None
        self.o: A = None
        self.t: D = None
        self.w: C = None
        self.q: E = None
        self.txt = txt

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

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

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

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

a = A("a")
n = B("n")
e = C("e")
h = D("h")
g = E("g")
f = F("f")

a.v = e
n.x = f
n.z = h
n.t = h
n.o = a
n.w = e
n.q = g
e.v = n
e.q = h
h.x = e
h.z = g
h.t = a
g.q = f
g.r = n
f.q = a
f.u = n
assert f.u.o.v.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.z: D = None
        self.o: A = None
        self.t: D = None
        self.w: C = None
        self.q: E = None
        self.txt = txt

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

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

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

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

a = A("a")
n = B("n")
e = C("e")
h = D("h")
g = E("g")
f = F("f")

a.v = e
n.x = f
n.z = h
n.t = h
n.o = a
n.w = e
n.q = g
e.v = n
e.q = h
h.x = e
h.z = g
h.t = a
g.q = f
g.r = n
f.q = a
f.u = n
assert f.u.o.v.v.z.txt == "h"