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

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

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

g = A("g")
h = B("h")
f = C("f")
a = B("a")
n = C("n")

g.y = n
h.v = g
f.u = g
f.v = g
f.w = n
a.v = g
n.u = g
n.v = g
n.w = f
assert g.y.u.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
f = C("f")
a = B("a")
n = C("n")

g.y = n
h.v = g
f.u = g
f.v = g
f.w = n
a.v = g
n.u = g
n.v = g
n.w = f
assert g.y.u.y.v.txt == "g"