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

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

j = A("j")
f = B("f")
d = A("d")
g = B("g")
h = A("h")
n = B("n")

j.x = h
f.o = d
d.x = h
g.o = j
h.x = j
n.o = d
assert j.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
d = A("d")
g = B("g")
h = A("h")
n = B("n")

j.x = h
f.o = d
d.x = h
g.o = j
h.x = j
n.o = d
assert j.x.x.x.x.x.x.txt == "j"