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

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

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

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

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

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

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

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

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

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

j.r = l
j.v = m
j.x = i
i.u = j
i.o = j
l.r = i
g.x = l
m.r = i
assert l.r.o.x.u.x.txt == "i"