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

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

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

l = A("l")
f = B("f")
n = C("n")
h = C("h")
k = A("k")
g = A("g")
b = C("b")

l.t = f
f.y = k
n.q = f
n.v = k
h.q = f
h.v = l
k.t = f
g.t = f
b.q = f
b.v = l
assert h.q.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
n = C("n")
h = C("h")
k = A("k")
g = A("g")
b = C("b")

l.t = f
f.y = k
n.q = f
n.v = k
h.q = f
h.v = l
k.t = f
g.t = f
b.q = f
b.v = l
assert h.q.y.t.y.txt == "k"