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

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

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

k = A("k")
l = B("l")
e = C("e")
b = B("b")
f = B("f")
n = C("n")

k.r = f
l.q = f
l.o = k
e.s = b
e.v = n
b.q = f
b.o = k
f.q = b
f.o = k
n.s = l
n.v = e
assert k.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
e = C("e")
b = B("b")
f = B("f")
n = C("n")

k.r = f
l.q = f
l.o = k
e.s = b
e.v = n
b.q = f
b.o = k
f.q = b
f.o = k
n.s = l
n.v = e
assert k.r.o.r.txt == "f"