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

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

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

n = A("n")
m = B("m")
c = C("c")
e = A("e")
j = B("j")
f = A("f")
d = C("d")

n.t = e
n.x = m
m.s = e
c.t = f
c.z = j
e.t = n
e.x = j
j.s = f
f.t = n
f.x = m
d.t = n
d.z = m
assert e.x.s.t.x.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.x: B = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
c = C("c")
e = A("e")
j = B("j")
f = A("f")
d = C("d")

n.t = e
n.x = m
m.s = e
c.t = f
c.z = j
e.t = n
e.x = j
j.s = f
f.t = n
f.x = m
d.t = n
d.z = m
assert e.x.s.t.x.s.t.txt == "n"