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

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

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

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

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

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

f = A("f")
c = B("c")
j = C("j")
d = D("d")
i = E("i")
h = F("h")

f.x = i
f.y = i
f.t = c
c.q = d
j.u = f
j.x = d
j.q = c
d.t = j
d.r = i
i.z = h
i.r = h
i.t = h
i.q = c
h.z = c
h.q = d
assert d.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.t: B = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

f = A("f")
c = B("c")
j = C("j")
d = D("d")
i = E("i")
h = F("h")

f.x = i
f.y = i
f.t = c
c.q = d
j.u = f
j.x = d
j.q = c
d.t = j
d.r = i
i.z = h
i.r = h
i.t = h
i.q = c
h.z = c
h.q = d
assert d.t.x.t.txt == "j"