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

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

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

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

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

g.s = l
g.u = m
m.x = l
m.r = d
l.x = g
l.t = g
l.p = g
l.v = m
d.x = l
d.s = g
assert l.v.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: B = None
        self.txt = txt

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

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

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

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

g.s = l
g.u = m
m.x = l
m.r = d
l.x = g
l.t = g
l.p = g
l.v = m
d.x = l
d.s = g
assert l.v.x.t.txt == "g"