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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: C = None
        self.z: E = None
        self.s: F = None
        self.u: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: E = None
        self.u: B = None
        self.o: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

n = A("n")
g = B("g")
h = C("h")
d = D("d")
c = E("c")
e = F("e")

n.q = d
g.y = n
g.o = h
g.z = c
g.u = c
g.s = e
h.p = d
h.w = c
h.o = c
h.u = g
d.q = e
d.v = g
c.s = d
e.s = n
e.z = d
assert d.v.y.q.v.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: C = None
        self.z: E = None
        self.s: F = None
        self.u: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: E = None
        self.u: B = None
        self.o: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

n = A("n")
g = B("g")
h = C("h")
d = D("d")
c = E("c")
e = F("e")

n.q = d
g.y = n
g.o = h
g.z = c
g.u = c
g.s = e
h.p = d
h.w = c
h.o = c
h.u = g
d.q = e
d.v = g
c.s = d
e.s = n
e.z = d
assert d.v.y.q.v.o.o.txt == "c"