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

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

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

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

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

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

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

m.v = n
m.q = k
h.r = n
h.x = n
h.y = i
k.q = g
k.x = g
k.y = n
k.p = m
k.s = i
n.s = i
n.q = m
n.w = m
n.o = g
n.y = h
g.o = k
g.v = h
i.s = n
i.w = n
i.u = h
i.t = h
i.q = m
assert g.v.y.q.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

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

m.v = n
m.q = k
h.r = n
h.x = n
h.y = i
k.q = g
k.x = g
k.y = n
k.p = m
k.s = i
n.s = i
n.q = m
n.w = m
n.o = g
n.y = h
g.o = k
g.v = h
i.s = n
i.w = n
i.u = h
i.t = h
i.q = m
assert g.v.y.q.v.s.txt == "i"