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

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.q: C = None
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

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

l.x = d
l.p = k
b.r = d
b.z = d
b.s = d
b.x = a
b.q = m
m.q = l
a.p = k
a.o = n
a.u = m
n.x = k
n.r = m
k.w = d
k.q = l
d.r = b
d.z = b
d.s = b
d.x = a
d.q = m
assert m.q.p.w.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.q: C = None
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

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

l.x = d
l.p = k
b.r = d
b.z = d
b.s = d
b.x = a
b.q = m
m.q = l
a.p = k
a.o = n
a.u = m
n.x = k
n.r = m
k.w = d
k.q = l
d.r = b
d.z = b
d.s = b
d.x = a
d.q = m
assert m.q.p.w.z.s.q.txt == "m"