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

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

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

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

b = A("b")
k = B("k")
g = C("g")
e = D("e")
d = D("d")

b.w = g
b.v = k
k.o = d
g.v = b
e.o = d
d.o = e
assert k.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: B = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
g = C("g")
e = D("e")
d = D("d")

b.w = g
b.v = k
k.o = d
g.v = b
e.o = d
d.o = e
assert k.o.o.o.txt == "d"