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

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

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

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

g = A("g")
k = B("k")
f = C("f")
l = D("l")
j = A("j")

g.x = f
k.w = l
k.x = g
k.v = j
f.o = l
l.v = f
j.x = f
assert f.o.v.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
f = C("f")
l = D("l")
j = A("j")

g.x = f
k.w = l
k.x = g
k.v = j
f.o = l
l.v = f
j.x = f
assert f.o.v.o.v.o.txt == "l"