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

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

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

i = A("i")
l = B("l")
d = C("d")
c = A("c")

i.x = l
l.v = d
l.u = c
d.r = l
c.x = l
assert l.v.r.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

i = A("i")
l = B("l")
d = C("d")
c = A("c")

i.x = l
l.v = d
l.u = c
d.r = l
c.x = l
assert l.v.r.u.x.txt == "l"