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

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

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

c = A("c")
h = B("h")
k = C("k")
a = B("a")
d = B("d")

c.o = d
c.x = k
h.s = c
k.s = c
k.v = c
a.s = c
d.s = c
assert h.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: C = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
k = C("k")
a = B("a")
d = B("d")

c.o = d
c.x = k
h.s = c
k.s = c
k.v = c
a.s = c
d.s = c
assert h.s.o.s.txt == "c"