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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: F = None
        self.o: F = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: C = None
        self.z: E = None
        self.o: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

d = A("d")
l = B("l")
f = C("f")
a = D("a")
m = E("m")
j = F("j")

d.q = l
l.v = f
l.r = d
l.x = d
f.w = d
f.z = j
f.o = j
f.x = a
a.x = m
a.z = m
a.y = f
a.o = f
m.r = l
j.o = l
j.x = l
assert m.r.v.w.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: F = None
        self.o: F = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: C = None
        self.z: E = None
        self.o: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

d = A("d")
l = B("l")
f = C("f")
a = D("a")
m = E("m")
j = F("j")

d.q = l
l.v = f
l.r = d
l.x = d
f.w = d
f.z = j
f.o = j
f.x = a
a.x = m
a.z = m
a.y = f
a.o = f
m.r = l
j.o = l
j.x = l
assert m.r.v.w.q.x.txt == "d"