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

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

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

h = A("h")
g = B("g")
b = C("b")
e = C("e")
n = A("n")
i = C("i")

h.u = g
h.y = g
h.z = g
g.w = e
g.r = n
g.v = b
b.o = n
e.o = n
n.u = g
n.y = g
n.z = g
i.o = n
assert e.o.y.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: B = None
        self.z: B = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
b = C("b")
e = C("e")
n = A("n")
i = C("i")

h.u = g
h.y = g
h.z = g
g.w = e
g.r = n
g.v = b
b.o = n
e.o = n
n.u = g
n.y = g
n.z = g
i.o = n
assert e.o.y.r.u.txt == "g"