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

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

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

j = A("j")
n = B("n")
b = C("b")
h = C("h")

j.v = n
n.t = b
n.x = b
b.q = h
b.t = j
h.q = b
h.t = j
assert j.v.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
b = C("b")
h = C("h")

j.v = n
n.t = b
n.x = b
b.q = h
b.t = j
h.q = b
h.t = j
assert j.v.t.q.txt == "h"