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

class B:
    def __init__(self, txt: str):
        self.t: F = None
        self.r: A = None
        self.w: E = None
        self.o: C = None
        self.txt = txt

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

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

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

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

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

m.x = f
d.t = a
d.r = m
d.w = i
d.o = j
j.u = i
j.y = f
j.z = f
j.v = d
f.p = i
f.t = a
f.x = a
i.x = m
i.z = m
i.u = f
a.u = m
assert f.t.u.x.t.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: F = None
        self.r: A = None
        self.w: E = None
        self.o: C = None
        self.txt = txt

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

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

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

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

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

m.x = f
d.t = a
d.r = m
d.w = i
d.o = j
j.u = i
j.y = f
j.z = f
j.v = d
f.p = i
f.t = a
f.x = a
i.x = m
i.z = m
i.u = f
a.u = m
assert f.t.u.x.t.u.x.txt == "f"