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

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

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

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

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

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

e = A("e")
g = B("g")
j = C("j")
b = D("b")
k = E("k")
d = F("d")

e.x = b
g.q = e
g.o = b
j.t = g
j.q = g
j.o = k
j.y = e
b.z = g
k.t = g
d.q = k
d.w = k
d.t = e
d.x = e
assert b.z.q.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

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

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

e = A("e")
g = B("g")
j = C("j")
b = D("b")
k = E("k")
d = F("d")

e.x = b
g.q = e
g.o = b
j.t = g
j.q = g
j.o = k
j.y = e
b.z = g
k.t = g
d.q = k
d.w = k
d.t = e
d.x = e
assert b.z.q.x.z.txt == "g"