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

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

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

g = A("g")
h = B("h")
k = C("k")
f = B("f")

g.x = k
h.v = k
k.w = h
k.x = h
f.v = k
assert h.v.x.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
k = C("k")
f = B("f")

g.x = k
h.v = k
k.w = h
k.x = h
f.v = k
assert h.v.x.v.w.txt == "h"