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

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

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

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

a.q = d
a.v = j
h.s = j
h.t = j
d.u = a
d.p = a
j.s = h
j.t = h
assert a.v.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: B = None
        self.txt = txt

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

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

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

a.q = d
a.v = j
h.s = j
h.t = j
d.u = a
d.p = a
j.s = h
j.t = h
assert a.v.s.s.txt == "j"