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

class B:
    def __init__(self, txt: str):
        self.x: D = 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.v: C = None
        self.txt = txt

i = A("i")
l = B("l")
d = C("d")
g = D("g")

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

class B:
    def __init__(self, txt: str):
        self.x: D = 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.v: C = None
        self.txt = txt

i = A("i")
l = B("l")
d = C("d")
g = D("g")

i.v = g
l.x = g
d.r = l
g.v = d
assert g.v.r.x.v.txt == "d"