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

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

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

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

a = A("a")
g = B("g")
h = C("h")
d = D("d")
j = C("j")
m = B("m")
e = D("e")
l = C("l")

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

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

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

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

a = A("a")
g = B("g")
h = C("h")
d = D("d")
j = C("j")
m = B("m")
e = D("e")
l = C("l")

a.s = g
a.u = g
a.y = h
g.r = a
g.v = a
g.o = d
g.x = l
h.s = a
d.w = e
d.s = h
j.s = a
m.r = a
m.v = a
m.o = d
m.x = j
e.w = d
e.s = j
l.s = a
assert g.x.s.s.o.s.s.txt == "a"