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

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

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

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

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

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

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

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

m.y = h
c.u = a
c.r = m
c.t = h
n.x = m
n.u = c
n.o = h
h.y = m
a.x = m
a.u = c
a.o = h
assert a.x.y.y.y.txt == "h"