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

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

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

b = A("b")
k = B("k")
d = C("d")
h = B("h")
j = C("j")
l = B("l")

b.s = h
b.x = l
k.y = b
k.s = b
d.w = l
d.s = b
d.o = j
h.y = b
h.s = b
j.w = k
j.s = b
j.o = d
l.y = b
l.s = b
assert l.y.s.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
d = C("d")
h = B("h")
j = C("j")
l = B("l")

b.s = h
b.x = l
k.y = b
k.s = b
d.w = l
d.s = b
d.o = j
h.y = b
h.s = b
j.w = k
j.s = b
j.o = d
l.y = b
l.s = b
assert l.y.s.y.x.y.txt == "b"