class A:
    def __init__(self, txt: str):
        self.v: C = 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.t: B = None
        self.w: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
k = C("k")
h = D("h")
d = B("d")

j.v = k
f.t = k
k.t = f
k.w = j
h.w = d
d.t = k
assert k.w.v.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = 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.t: B = None
        self.w: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
k = C("k")
h = D("h")
d = B("d")

j.v = k
f.t = k
k.t = f
k.w = j
h.w = d
d.t = k
assert k.w.v.w.v.w.txt == "j"