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

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: B = None
        self.y: A = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.w: B = None
        self.y: A = None
        self.txt = txt

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

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

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