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

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

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

j = A("j")
c = B("c")
k = C("k")
h = C("h")

j.w = h
c.x = h
c.t = j
c.q = k
k.q = c
h.q = c
assert h.q.q.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
k = C("k")
h = C("h")

j.w = h
c.x = h
c.t = j
c.q = k
k.q = c
h.q = c
assert h.q.q.q.x.txt == "h"