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

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

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

l = A("l")
i = B("i")
e = C("e")
n = B("n")
f = B("f")
m = A("m")

l.x = n
i.o = f
i.s = l
i.r = m
e.s = l
n.o = f
n.s = l
n.r = l
f.o = n
f.s = l
f.r = l
m.x = f
assert n.r.x.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
e = C("e")
n = B("n")
f = B("f")
m = A("m")

l.x = n
i.o = f
i.s = l
i.r = m
e.s = l
n.o = f
n.s = l
n.r = l
f.o = n
f.s = l
f.r = l
m.x = f
assert n.r.x.o.o.txt == "n"