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

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

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

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

a = A("a")
j = B("j")
d = C("d")
k = D("k")
b = D("b")
n = C("n")

a.y = k
a.z = b
a.t = j
a.x = j
j.t = a
d.w = j
k.o = a
k.r = b
b.o = a
b.r = k
n.w = j
assert n.w.t.t.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: D = None
        self.t: B = None
        self.x: B = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
d = C("d")
k = D("k")
b = D("b")
n = C("n")

a.y = k
a.z = b
a.t = j
a.x = j
j.t = a
d.w = j
k.o = a
k.r = b
b.o = a
b.r = k
n.w = j
assert n.w.t.t.t.z.txt == "b"