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

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

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

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

a = A("a")
l = B("l")
d = C("d")
b = D("b")
k = B("k")
f = A("f")

a.u = l
l.o = a
l.s = a
l.q = f
l.y = k
d.t = k
d.u = b
d.y = f
b.v = k
b.o = k
k.o = f
k.s = f
k.q = a
k.y = l
f.u = k
assert a.u.o.u.o.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
d = C("d")
b = D("b")
k = B("k")
f = A("f")

a.u = l
l.o = a
l.s = a
l.q = f
l.y = k
d.t = k
d.u = b
d.y = f
b.v = k
b.o = k
k.o = f
k.s = f
k.q = a
k.y = l
f.u = k
assert a.u.o.u.o.u.s.txt == "a"