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: B = None
        self.txt = txt

f = A("f")
n = B("n")
c = B("c")
k = B("k")
i = B("i")

f.r = k
n.q = c
n.o = i
c.q = n
c.o = i
k.q = n
k.o = i
i.q = k
i.o = n
assert f.r.q.o.o.o.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: B = None
        self.txt = txt

f = A("f")
n = B("n")
c = B("c")
k = B("k")
i = B("i")

f.r = k
n.q = c
n.o = i
c.q = n
c.o = i
k.q = n
k.o = i
i.q = k
i.o = n
assert f.r.q.o.o.o.txt == "i"