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

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

h = A("h")
a = B("a")
i = A("i")
k = B("k")

h.v = k
h.o = a
a.r = i
a.u = k
i.v = k
i.o = k
k.r = i
k.u = a
assert i.v.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.txt = txt

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

h = A("h")
a = B("a")
i = A("i")
k = B("k")

h.v = k
h.o = a
a.r = i
a.u = k
i.v = k
i.o = k
k.r = i
k.u = a
assert i.v.r.v.txt == "k"