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

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

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

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

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

g.t = f
g.u = e
g.x = e
f.s = g
j.y = g
j.p = d
j.s = f
d.t = e
d.p = f
d.r = f
d.v = g
e.t = d
e.p = f
e.r = f
e.v = g
l.t = d
l.p = f
l.r = f
l.v = g
assert d.v.x.v.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

g.t = f
g.u = e
g.x = e
f.s = g
j.y = g
j.p = d
j.s = f
d.t = e
d.p = f
d.r = f
d.v = g
e.t = d
e.p = f
e.r = f
e.v = g
l.t = d
l.p = f
l.r = f
l.v = g
assert d.v.x.v.t.s.txt == "g"