class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: 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.x: B = None
        self.t: B = None
        self.txt = txt

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

n.z = h
n.w = b
f.v = h
b.u = h
b.x = c
b.t = c
g.v = n
a.v = h
h.z = n
h.w = b
c.v = h
l.v = h
assert b.u.w.u.w.t.v.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: 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.x: B = None
        self.t: B = None
        self.txt = txt

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

n.z = h
n.w = b
f.v = h
b.u = h
b.x = c
b.t = c
g.v = n
a.v = h
h.z = n
h.w = b
c.v = h
l.v = h
assert b.u.w.u.w.t.v.w.t.txt == "c"