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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: D = None
        self.q: E = None
        self.r: E = None
        self.s: D = None
        self.txt = txt

g = A("g")
b = B("b")
m = C("m")
k = D("k")
a = E("a")
d = F("d")
n = A("n")

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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: D = None
        self.q: E = None
        self.r: E = None
        self.s: D = None
        self.txt = txt

g = A("g")
b = B("b")
m = C("m")
k = D("k")
a = E("a")
d = F("d")
n = A("n")

g.q = n
b.s = n
m.z = d
k.y = m
a.x = d
d.z = k
d.t = k
d.s = k
d.q = a
d.r = a
n.q = g
assert a.x.q.x.txt == "d"