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

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

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

b = A("b")
a = B("a")
d = C("d")
h = B("h")
g = A("g")

b.p = d
b.u = d
b.z = d
a.v = g
a.y = d
d.x = h
d.v = a
d.w = b
h.v = g
h.y = d
g.p = d
g.u = d
g.z = d
assert g.u.x.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.z: C = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
d = C("d")
h = B("h")
g = A("g")

b.p = d
b.u = d
b.z = d
a.v = g
a.y = d
d.x = h
d.v = a
d.w = b
h.v = g
h.y = d
g.p = d
g.u = d
g.z = d
assert g.u.x.y.w.txt == "b"