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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: B = None
        self.o: B = None
        self.txt = txt

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

a.v = h
a.q = m
a.z = k
b.u = k
b.r = m
n.u = b
n.v = b
n.z = a
n.x = h
m.r = a
m.z = n
m.t = n
h.r = m
h.o = k
h.z = a
k.q = m
k.x = b
k.o = b
assert k.x.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.q: D = None
        self.z: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: B = None
        self.o: B = None
        self.txt = txt

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

a.v = h
a.q = m
a.z = k
b.u = k
b.r = m
n.u = b
n.v = b
n.z = a
n.x = h
m.r = a
m.z = n
m.t = n
h.r = m
h.o = k
h.z = a
k.q = m
k.x = b
k.o = b
assert k.x.r.r.q.txt == "m"