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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
i = C("i")
h = D("h")
a = A("a")

l.v = i
l.u = h
g.y = l
g.p = l
g.o = a
i.w = g
h.u = g
h.x = i
a.v = i
a.u = h
assert a.u.u.y.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
i = C("i")
h = D("h")
a = A("a")

l.v = i
l.u = h
g.y = l
g.p = l
g.o = a
i.w = g
h.u = g
h.x = i
a.v = i
a.u = h
assert a.u.u.y.v.w.txt == "g"