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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
g = C("g")
a = D("a")
e = E("e")
n = F("n")

j.x = a
j.s = n
j.z = e
f.w = e
f.v = a
f.z = j
g.w = a
a.q = n
e.r = g
n.t = e
n.q = j
assert n.q.s.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.s: F = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
g = C("g")
a = D("a")
e = E("e")
n = F("n")

j.x = a
j.s = n
j.z = e
f.w = e
f.v = a
f.z = j
g.w = a
a.q = n
e.r = g
n.t = e
n.q = j
assert n.q.s.t.r.txt == "g"