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

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

g = A("g")
a = B("a")
e = C("e")
i = D("i")
k = A("k")

g.u = e
a.y = i
a.s = e
a.w = e
a.o = g
e.v = k
i.o = a
k.u = e
assert e.v.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

g = A("g")
a = B("a")
e = C("e")
i = D("i")
k = A("k")

g.u = e
a.y = i
a.s = e
a.w = e
a.o = g
e.v = k
i.o = a
k.u = e
assert e.v.u.v.u.txt == "e"