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

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

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

m = A("m")
b = B("b")
n = C("n")
j = B("j")
h = A("h")
e = B("e")

m.r = h
m.x = b
b.s = n
b.t = m
b.u = j
n.r = j
n.o = h
j.s = n
j.t = h
j.u = b
h.r = m
h.x = b
e.s = n
e.t = m
e.u = j
assert e.s.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: B = None
        self.txt = txt

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

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

m = A("m")
b = B("b")
n = C("n")
j = B("j")
h = A("h")
e = B("e")

m.r = h
m.x = b
b.s = n
b.t = m
b.u = j
n.r = j
n.o = h
j.s = n
j.t = h
j.u = b
h.r = m
h.x = b
e.s = n
e.t = m
e.u = j
assert e.s.o.r.txt == "m"