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

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

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

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

b = A("b")
c = B("c")
e = C("e")
a = D("a")
l = C("l")
d = D("d")
i = C("i")
g = B("g")
j = A("j")
h = A("h")

b.r = a
b.x = e
c.o = g
c.v = g
c.t = e
e.s = c
a.v = h
l.s = g
d.v = b
i.s = c
g.o = c
g.v = c
g.t = l
j.r = d
j.x = i
h.r = a
h.x = l
assert d.v.r.v.x.s.o.v.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

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

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

b = A("b")
c = B("c")
e = C("e")
a = D("a")
l = C("l")
d = D("d")
i = C("i")
g = B("g")
j = A("j")
h = A("h")

b.r = a
b.x = e
c.o = g
c.v = g
c.t = e
e.s = c
a.v = h
l.s = g
d.v = b
i.s = c
g.o = c
g.v = c
g.t = l
j.r = d
j.x = i
h.r = a
h.x = l
assert d.v.r.v.x.s.o.v.v.o.txt == "g"