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

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

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

i.o = d
k.x = c
c.x = n
n.x = d
f.x = d
d.x = c
assert c.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

i.o = d
k.x = c
c.x = n
n.x = d
f.x = d
d.x = c
assert c.x.x.x.txt == "c"