class A:
    def __init__(self, txt: str):
        self.z: 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.v: A = None
        self.z: B = None
        self.txt = txt

h = A("h")
n = B("n")
b = C("b")
j = C("j")
e = B("e")
g = A("g")
d = C("d")

h.z = e
n.t = j
n.x = b
b.v = g
b.z = n
j.v = g
j.z = n
e.t = j
e.x = b
g.z = n
d.v = h
d.z = n
assert j.z.t.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: 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.v: A = None
        self.z: B = None
        self.txt = txt

h = A("h")
n = B("n")
b = C("b")
j = C("j")
e = B("e")
g = A("g")
d = C("d")

h.z = e
n.t = j
n.x = b
b.v = g
b.z = n
j.v = g
j.z = n
e.t = j
e.x = b
g.z = n
d.v = h
d.z = n
assert j.z.t.v.z.txt == "n"