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

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

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

f = A("f")
j = B("j")
h = C("h")
d = C("d")

f.v = d
f.x = d
f.o = d
j.x = f
j.w = f
j.r = d
h.r = f
d.r = f
assert f.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
j = B("j")
h = C("h")
d = C("d")

f.v = d
f.x = d
f.o = d
j.x = f
j.w = f
j.r = d
h.r = f
d.r = f
assert f.x.r.x.txt == "d"