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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: C = None
        self.z: E = None
        self.p: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: C = None
        self.z: C = None
        self.q: C = None
        self.s: B = None
        self.txt = txt

c = A("c")
a = B("a")
d = C("d")
g = D("g")
m = E("m")
l = F("l")

c.w = l
a.p = g
d.q = c
d.v = l
g.s = c
g.o = d
g.z = m
g.p = m
m.q = g
m.y = a
m.z = c
l.t = d
l.w = d
l.z = d
l.q = d
l.s = a
assert m.y.p.s.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: C = None
        self.z: E = None
        self.p: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.w: C = None
        self.z: C = None
        self.q: C = None
        self.s: B = None
        self.txt = txt

c = A("c")
a = B("a")
d = C("d")
g = D("g")
m = E("m")
l = F("l")

c.w = l
a.p = g
d.q = c
d.v = l
g.s = c
g.o = d
g.z = m
g.p = m
m.q = g
m.y = a
m.z = c
l.t = d
l.w = d
l.z = d
l.q = d
l.s = a
assert m.y.p.s.w.z.txt == "d"