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

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

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

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

g = A("g")
e = B("e")
l = C("l")
j = D("j")

g.v = e
g.o = e
g.s = l
e.r = g
l.s = j
l.w = j
l.p = e
j.x = l
assert e.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: C = None
        self.o: B = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
l = C("l")
j = D("j")

g.v = e
g.o = e
g.s = l
e.r = g
l.s = j
l.w = j
l.p = e
j.x = l
assert e.r.o.r.txt == "g"