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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: B = None
        self.s: E = None
        self.t: D = None
        self.txt = txt

m = A("m")
c = B("c")
n = C("n")
j = D("j")
i = E("i")
a = F("a")
d = E("d")

m.q = j
c.s = j
c.v = m
c.o = m
c.q = n
n.s = m
j.u = a
j.y = a
j.z = n
j.r = c
i.o = m
i.y = m
a.u = c
a.y = c
a.s = d
a.t = j
d.o = m
d.y = m
assert j.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: B = None
        self.s: E = None
        self.t: D = None
        self.txt = txt

m = A("m")
c = B("c")
n = C("n")
j = D("j")
i = E("i")
a = F("a")
d = E("d")

m.q = j
c.s = j
c.v = m
c.o = m
c.q = n
n.s = m
j.u = a
j.y = a
j.z = n
j.r = c
i.o = m
i.y = m
a.u = c
a.y = c
a.s = d
a.t = j
d.o = m
d.y = m
assert j.z.s.q.txt == "j"