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

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

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

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

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

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

a = A("a")
j = B("j")
b = C("b")
f = D("f")
m = E("m")
g = F("g")
d = C("d")
i = B("i")

a.x = b
j.q = g
b.z = g
b.y = a
f.s = m
m.y = d
m.t = g
g.z = j
g.r = b
g.q = b
g.y = m
g.u = m
g.x = f
d.z = g
d.y = a
i.q = g
assert i.q.z.q.y.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

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

a = A("a")
j = B("j")
b = C("b")
f = D("f")
m = E("m")
g = F("g")
d = C("d")
i = B("i")

a.x = b
j.q = g
b.z = g
b.y = a
f.s = m
m.y = d
m.t = g
g.z = j
g.r = b
g.q = b
g.y = m
g.u = m
g.x = f
d.z = g
d.y = a
i.q = g
assert i.q.z.q.y.y.z.txt == "g"