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

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

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

f = A("f")
c = B("c")
d = C("d")
j = A("j")
i = B("i")

f.o = d
f.p = j
f.x = j
c.x = i
c.w = d
d.t = c
j.o = d
j.p = f
j.x = f
i.x = c
i.w = d
assert c.w.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: A = None
        self.x: A = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
d = C("d")
j = A("j")
i = B("i")

f.o = d
f.p = j
f.x = j
c.x = i
c.w = d
d.t = c
j.o = d
j.p = f
j.x = f
i.x = c
i.w = d
assert c.w.t.x.txt == "i"