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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: B = None
        self.x: B = None
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
k = C("k")
i = D("i")
n = A("n")
m = B("m")
d = D("d")

f.t = n
f.p = k
f.s = h
h.p = k
h.o = k
h.z = m
h.x = m
k.u = m
k.q = d
k.z = n
i.q = h
i.y = k
i.p = k
i.x = n
n.t = f
n.p = k
n.s = h
m.p = k
m.o = k
m.z = h
m.x = h
d.q = h
d.y = k
d.p = k
d.x = f
assert h.p.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: C = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: B = None
        self.x: B = None
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
k = C("k")
i = D("i")
n = A("n")
m = B("m")
d = D("d")

f.t = n
f.p = k
f.s = h
h.p = k
h.o = k
h.z = m
h.x = m
k.u = m
k.q = d
k.z = n
i.q = h
i.y = k
i.p = k
i.x = n
n.t = f
n.p = k
n.s = h
m.p = k
m.o = k
m.z = h
m.x = h
d.q = h
d.y = k
d.p = k
d.x = f
assert h.p.q.x.txt == "f"