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

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

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

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

m = A("m")
k = B("k")
l = C("l")
c = D("c")
g = A("g")
i = C("i")

m.v = i
m.x = g
m.u = g
k.o = c
k.z = g
l.r = i
c.v = l
g.v = l
g.x = m
g.u = m
i.r = l
assert m.u.u.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
l = C("l")
c = D("c")
g = A("g")
i = C("i")

m.v = i
m.x = g
m.u = g
k.o = c
k.z = g
l.r = i
c.v = l
g.v = l
g.x = m
g.u = m
i.r = l
assert m.u.u.x.v.txt == "l"