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

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

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

j = A("j")
e = B("e")
h = C("h")
n = C("n")
g = B("g")

j.r = e
j.s = h
e.u = g
e.z = j
h.x = n
n.x = h
g.u = e
g.z = j
assert n.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: C = None
        self.txt = txt

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

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

j = A("j")
e = B("e")
h = C("h")
n = C("n")
g = B("g")

j.r = e
j.s = h
e.u = g
e.z = j
h.x = n
n.x = h
g.u = e
g.z = j
assert n.x.x.x.txt == "h"