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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: C = None
        self.q: F = None
        self.p: B = None
        self.w: D = None
        self.txt = txt

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

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

i.x = m
j.x = i
g.t = j
g.q = a
a.p = m
a.w = g
a.y = j
m.r = i
m.v = g
m.q = d
m.p = j
m.w = a
d.q = m
d.w = i
d.x = g
assert i.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: C = None
        self.q: F = None
        self.p: B = None
        self.w: D = None
        self.txt = txt

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

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

i.x = m
j.x = i
g.t = j
g.q = a
a.p = m
a.w = g
a.y = j
m.r = i
m.v = g
m.q = d
m.p = j
m.w = a
d.q = m
d.w = i
d.x = g
assert i.x.q.x.txt == "g"