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

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

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

l = A("l")
j = B("j")
i = C("i")
d = B("d")
k = C("k")
e = A("e")
b = B("b")
a = C("a")

l.z = a
l.r = i
j.s = b
i.o = e
i.p = e
i.x = k
d.s = b
k.o = l
k.p = l
k.x = i
e.z = i
e.r = a
b.s = j
a.o = e
a.x = k
a.p = l
assert d.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
i = C("i")
d = B("d")
k = C("k")
e = A("e")
b = B("b")
a = C("a")

l.z = a
l.r = i
j.s = b
i.o = e
i.p = e
i.x = k
d.s = b
k.o = l
k.p = l
k.x = i
e.z = i
e.r = a
b.s = j
a.o = e
a.x = k
a.p = l
assert d.s.s.s.s.s.s.s.txt == "b"