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

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

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

f = A("f")
d = B("d")
g = C("g")
l = C("l")
i = B("i")
j = A("j")
k = B("k")

f.o = g
f.x = j
d.r = k
g.q = l
g.r = f
g.o = j
l.q = g
l.r = j
l.o = j
i.r = k
j.o = l
j.x = f
k.r = i
assert l.r.x.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: A = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
g = C("g")
l = C("l")
i = B("i")
j = A("j")
k = B("k")

f.o = g
f.x = j
d.r = k
g.q = l
g.r = f
g.o = j
l.q = g
l.r = j
l.o = j
i.r = k
j.o = l
j.x = f
k.r = i
assert l.r.x.o.o.o.txt == "l"