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

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

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

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

n = A("n")
g = B("g")
e = C("e")
b = D("b")
l = B("l")

n.s = e
g.s = l
g.u = n
e.u = b
e.r = b
e.y = g
e.s = n
b.o = n
l.s = g
l.u = n
assert l.u.s.s.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
e = C("e")
b = D("b")
l = B("l")

n.s = e
g.s = l
g.u = n
e.u = b
e.r = b
e.y = g
e.s = n
b.o = n
l.s = g
l.u = n
assert l.u.s.s.s.u.txt == "b"