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

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

c = A("c")
b = B("b")
n = A("n")
k = A("k")
a = B("a")
j = B("j")
f = A("f")

c.o = k
b.x = a
b.t = a
n.o = f
k.o = n
a.x = j
a.t = j
j.x = b
j.t = a
f.o = k
assert a.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

c = A("c")
b = B("b")
n = A("n")
k = A("k")
a = B("a")
j = B("j")
f = A("f")

c.o = k
b.x = a
b.t = a
n.o = f
k.o = n
a.x = j
a.t = j
j.x = b
j.t = a
f.o = k
assert a.t.t.t.t.txt == "a"