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

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

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

h = A("h")
i = B("i")
m = C("m")
a = B("a")
f = A("f")
j = C("j")

h.u = a
h.y = f
i.t = a
i.r = a
i.s = h
m.t = j
m.y = h
m.u = i
a.t = i
a.r = i
a.s = f
f.u = a
f.y = h
j.t = m
j.y = f
j.u = a
assert j.t.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: A = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
m = C("m")
a = B("a")
f = A("f")
j = C("j")

h.u = a
h.y = f
i.t = a
i.r = a
i.s = h
m.t = j
m.y = h
m.u = i
a.t = i
a.r = i
a.s = f
f.u = a
f.y = h
j.t = m
j.y = f
j.u = a
assert j.t.y.y.txt == "f"