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

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

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

n = A("n")
a = B("a")
e = C("e")
c = B("c")
h = C("h")

n.s = h
n.r = h
a.u = h
a.s = c
a.r = n
e.o = n
e.x = h
e.y = h
c.u = h
c.s = a
c.r = n
h.o = n
h.x = e
h.y = e
assert a.u.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: C = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
e = C("e")
c = B("c")
h = C("h")

n.s = h
n.r = h
a.u = h
a.s = c
a.r = n
e.o = n
e.x = h
e.y = h
c.u = h
c.s = a
c.r = n
h.o = n
h.x = e
h.y = e
assert a.u.o.r.txt == "h"