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

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

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

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

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

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

j = A("j")
k = B("k")
m = C("m")
g = D("g")
f = E("f")
e = F("e")

j.w = k
j.x = f
k.z = f
k.q = e
k.x = g
m.w = e
m.u = k
m.x = k
g.r = j
f.o = j
f.t = g
e.u = g
e.z = j
assert m.w.z.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: E = None
        self.txt = txt

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

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

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

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

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

j = A("j")
k = B("k")
m = C("m")
g = D("g")
f = E("f")
e = F("e")

j.w = k
j.x = f
k.z = f
k.q = e
k.x = g
m.w = e
m.u = k
m.x = k
g.r = j
f.o = j
f.t = g
e.u = g
e.z = j
assert m.w.z.x.t.txt == "g"