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

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

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: D = None
        self.u: E = None
        self.o: B = None
        self.txt = txt

h = A("h")
i = B("i")
a = C("a")
b = D("b")
f = E("f")
d = F("d")

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

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

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: D = None
        self.u: E = None
        self.o: B = None
        self.txt = txt

h = A("h")
i = B("i")
a = C("a")
b = D("b")
f = E("f")
d = F("d")

h.t = d
i.t = a
a.r = b
a.w = h
a.q = h
b.x = i
f.z = i
f.p = i
f.q = i
f.y = h
f.u = d
f.v = a
d.w = f
d.u = f
d.x = b
d.o = i
assert d.x.x.t.txt == "a"