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

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

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

d = A("d")
i = B("i")
h = C("h")
g = A("g")
n = A("n")

d.y = n
d.x = n
d.t = i
i.s = g
i.y = g
i.x = n
h.q = g
h.t = d
g.y = n
g.x = d
g.t = i
n.y = g
n.x = d
n.t = i
assert n.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: A = None
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
h = C("h")
g = A("g")
n = A("n")

d.y = n
d.x = n
d.t = i
i.s = g
i.y = g
i.x = n
h.q = g
h.t = d
g.y = n
g.x = d
g.t = i
n.y = g
n.x = d
n.t = i
assert n.t.x.x.txt == "d"