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

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

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

j = A("j")
i = B("i")
h = C("h")
e = B("e")

j.q = i
j.v = e
i.u = j
i.w = e
h.q = j
h.x = e
e.u = j
e.w = i
assert i.u.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
i = B("i")
h = C("h")
e = B("e")

j.q = i
j.v = e
i.u = j
i.w = e
h.q = j
h.x = e
e.u = j
e.w = i
assert i.u.v.u.v.txt == "e"