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

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

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

h = A("h")
i = B("i")
n = C("n")
e = C("e")
k = A("k")
f = A("f")
j = C("j")

h.o = f
h.u = i
h.r = k
i.r = k
n.x = f
e.x = f
k.o = f
k.r = f
k.u = i
f.o = k
f.u = i
f.r = h
j.x = f
assert k.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: B = None
        self.r: A = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
n = C("n")
e = C("e")
k = A("k")
f = A("f")
j = C("j")

h.o = f
h.u = i
h.r = k
i.r = k
n.x = f
e.x = f
k.o = f
k.r = f
k.u = i
f.o = k
f.u = i
f.r = h
j.x = f
assert k.u.r.u.txt == "i"