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

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

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

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

j = A("j")
m = B("m")
i = C("i")
d = D("d")
f = D("f")
a = B("a")

j.x = i
j.t = d
m.w = a
i.u = d
i.p = j
d.v = m
f.v = a
a.w = m
assert a.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: D = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
i = C("i")
d = D("d")
f = D("f")
a = B("a")

j.x = i
j.t = d
m.w = a
i.u = d
i.p = j
d.v = m
f.v = a
a.w = m
assert a.w.w.w.w.txt == "a"